以下是触发PropertyChanged的属性:
public override List<Tag> Tags
{
get
{
return base.Tags;
}
set
{
if (base.Tags != value) {
base.Tags = value;
if (PropertyChanged != null)
{
PropertyChanged(this,
new PropertyChangedEventArgs("Tags"));
PropertyChanged(this,
new PropertyChangedEventArgs("TotalTagPages"));
PropertyChanged(this,
new PropertyChangedEventArgs("PageHasTags"));
}
}
}
}
当修改CurrentPage.Tags时,此控件正确刷新:
<TextBlock DockPanel.Dock="Bottom" Name="TagHeader"
Text="{Binding CurrentPage.Tags,
Converter={converter:EnumerableToSpacedString}}"
Foreground="White" />
更改CurrentPage.Tags时不刷新,但更改CurrentPage本身时会这样做:
<ListBox VerticalAlignment="Top"
Style="{StaticResource DarkListBox}"
ItemTemplate="{StaticResource TagTemplateNoCounts}"
ItemsSource="{Binding CurrentPage.Tags}" >
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"></StackPanel>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>
有什么想法吗?