WPF 枚举绑定不刷新

WPF enum binding do not refresh

所以基本上我有一个绑定到 WPF 数据网格的对象的 ObservableCollection。 问题在于枚举类型 属性 - SyncState - 它不会在网格行中刷新,但它的工具提示会正确刷新。

XAML:

<DataGridTextColumn Binding="{Binding SyncState}" ClipboardContentBinding="{x:Null}" Header="Stan">
                                <DataGridTextColumn.CellStyle>
                                    <Style TargetType="DataGridCell">
                                        <Setter Property="ToolTip">
                                            <Setter.Value>
                                                <TextBlock Text="{Binding SyncState}" />
                                            </Setter.Value>
                                        </Setter>
                                    </Style>
                                </DataGridTextColumn.CellStyle>
                            </DataGridTextColumn>

对象Class:

class TechnologyFile
{
    public string TechName { get; private set; }
    public string FilePath { get; private set; }
    public DateTime FileDate { get; set; }
    public AuxFunctions.SyncState SyncState { get; set; }
}

效果:

如您所见 - 工具提示是正确的 - SyncState 确实是 "NoFile"。为什么数据网格行显示不同的内容?

您的 class 需要实施 INotifyPropertyChanged 并在 属性 的值更改时引发 PropertyChanged 事件。

我想工具提示是正确的,因为它在显示时请求对象的值,因此在 属性 具有更改值的时候。