1
我有以下情形:更改属性不会影响实际的对象
<Setter Property="ItemsSource">
<Setter.Value>
<MultiBinding Converter="{StaticResource itemsSourceConv}" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged">
<Binding Path="DataSource" RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=UserControl}"></Binding>
<Binding Path="DataSet" UpdateSourceTrigger="PropertyChanged" Mode="TwoWay"></Binding>
</MultiBinding>
</Setter.Value>
</Setter>
我有被绑定到某些数据的控制依赖项属性。 在控件的XAML中,我有这个代码,它必须从DependancyProperty中获取数据并将其传递给控件的视图模型。
我已经确定使用Multi Binding可以更容易地完成它。
问题是在我执行转换器后控制ViewModel内的DataSet属性没有设置。
这里的MultiBinding转换器看起来像
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
var dataFromWindow = values[0] as List<object>;
var controlViewModel = values[1];
controlViewModel = dataFromWindow ; //After execution this object is changed but the object that values[1] references in the viewmodel isn't changed.
return dataFromWindow;
}
不MultiBinding创建我通过它,而不是与引用它的工作对象的副本?
编辑:
由转换器内部直接分配DataContext.DataSet解决。
工作,谢谢:)) – Hristo