我正在使用twoway绑定动态更改我的一个用户控件的颜色并设置初始选定的颜色。它的结构如下(简化方式):
<RadGridView x:Name="T" ItemsSource="{Binding storage, Mode=OneWay}">
<GridViewColumn>
<GridViewColumn.Template>
<ColorPicker SelectedColor="{Binding Color, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
</...>
</...>
</...>
关联的C#代码:
void func(object sender) {
this.DataContext = sender;
}
当我尝试更改GridView IF的DataContext时,我得到一个nullpointer异常,并且只有GridView中有元素。有没有办法绕过改变具有twoway绑定的gridview的源?
最佳, 金