WPF通知对象的更改

Eri*_*k Z 0 wpf

我有一个gridview,我定义了一些列,像这样......

<GridViewColumn.CellTemplate>
    <DataTemplate>
        <TextBlock Text="{Binding MyProp}" />
    </DataTemplate>
</GridViewColumn.CellTemplate>
Run Code Online (Sandbox Code Playgroud)

我将gridview绑定到一个集合,并在属性MyProp中实现INotifyPropertyChanged.这很有效,MyProp的任何更改都会反映到gridview中.

如果我添加另一个绑定到对象本身的列,我不会收到任何通知/更新.我的代码......

<GridViewColumn.CellTemplate>
    <DataTemplate>
        <TextBlock Text="{Binding Converter={StaticResource myConverter}}"/>
    </DataTemplate>
</GridViewColumn.CellTemplate>
Run Code Online (Sandbox Code Playgroud)

我想我需要像对象一样的INotifyPropertyChanged,但我不知道如何做到这一点.有什么建议?

Mat*_*ton 5

是的,实际的实例本身永远不会改变 - 只有它的属性.

大概你的转换器依赖于你绑定的对象的一堆属性?如果是这样,您可以使用MultiBinding并将转换器更改为IMultiValueConverter.然后,您可以绑定到可能导致TextBlock更新的所有依赖属性.