1

这是触发 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>

有任何想法吗?

4

1 回答 1

2

看不出有任何不可行的原因(与修改列表相反,这需要INotifyCollectionChanged)...

于 2012-08-24T16:38:01.753 回答