0
我通过绑定从不同线程(Task)更新DataGrid。无法从另一个线程(WPF)绑定DataGridTextColumn属性
我没有更新列值的问题。
<DataGridTextColumn Header="NAME" MinWidth="100" Width="10*" Binding="{Binding name}" />
但是,我的一些列也应该有不同的背景颜色来自数据库。我无法更新背景属性。
<DataGridTextColumn Header="" Width="10">
<DataGridTextColumn.CellStyle>
<Style TargetType="DataGridCell">
<Setter Property="Background" Value="{Binding color}" />
</Style>
</DataGridTextColumn.CellStyle>
</DataGridTextColumn>
我遇到这个问题:
必须在相同的线程创建DependencySource作为DependencyObject的
能否请你指点什么,我需要做什么?
P.S. Freeze()有帮助,但我认为这不是一种方法。
您不应该从另一个线程访问WPF控件。只有UI线程才能访问GUI。 –
你可以发布你正在更新'color'的代码吗?属性 – MrZander
你应该调用在这个线程上创建控件的更新 – EMUEVIL