我在 SO 上找到了一些关于这个问题的条目,但它们并不令我满意。他们谈论 INotifyProperyChanged,但这对我的情况没有帮助。
我有一个组合框
。
对于 ItemsSource
,我使用一个 MultiBinding
和一个 Converter
来创建一个 ICollectionView
。 ICollectionView
绑定(bind)到 ItemsSource
。
在 GotFocus
事件中,需要刷新此绑定(bind),因此转换器会再次触发。
我该怎么做?
最佳答案
好的,一位同事帮助了我。
这是解决方案:
private void theComboBox_OnGotFocus(object sender, RoutedEventArgs e)
{
ComboBox theComboBox = sender as ComboBox;
if (theComboBox != null)
{
MultiBindingExpression binding = BindingOperations.GetMultiBindingExpression(theComboBox, ComboBox.ItemsSourceProperty);
if (binding != null)
{
binding.UpdateTarget();
}
}
}
关于c# - 如何以编程方式刷新组合框的项目源的绑定(bind)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1137538/