【问题标题】:How to refresh the combobox ItemSource after loading?加载后如何刷新组合框ItemSsource?
【发布时间】:2013-06-14 16:08:18
【问题描述】:

我是 WPF 新手:

我有一个组合框,其 ItemsSource 正在更改。这不会反映给用户。我必须将 ItemsSource 模式指定为 TwoWay 吗?

有什么建议吗?

<ComboBox Height="Auto" Name="comboBoxQuery" Width="300" IsEditable="True" ItemsSource="{Binding QueryNames, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" SelectedItem="{Binding SelectedQueryNames, Mode=TwoWay}" SelectedValuePath="Key" DisplayMemberPath="Value" Visibility="Collapsed" /> <!--Is this correct? -->

【问题讨论】:

    标签: wpf xaml data-binding combobox


    【解决方案1】:

    为了告诉视图集合源已经改变,你应该使用支持INotifyCollectionChanged接口的集合类。例如:ObservableCollectionBindingList。您不需要 TwoWay 数据绑定,WPF 会检测到源集合支持 INotifyCollectionChanged 接口,并且您在该集合中所做的所有更改都会反映视图。

    【讨论】:

      猜你喜欢
      • 2011-12-16
      • 2010-11-11
      • 1970-01-01
      • 2016-06-12
      • 2016-02-15
      • 2013-03-24
      • 2014-04-10
      • 2013-02-25
      • 2018-05-21
      相关资源
      最近更新 更多