我在wpf窗口绑定了datagrid。我添加了一个无界的列,并希望在任何事件中设置值。我怎么能这样做?
<DataGrid.Columns>
<DataGridCheckBoxColumn x:Name="delFlgColumn" Binding="{Binding Path=DelFlg, NotifyOnTargetUpdated=True, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" Header="Del Flg" Width="SizeToHeader" Visibility="Hidden"/>
<DataGridTextColumn x:Name="ModeFlgColumn" Header="Mode" Width="SizeToHeader" Visibility="Visible" />
</DataGrid.Columns>
</DataGrid>
我想设置&#34; D&#34;在ModeFlgColumn中,用户检查复选框delFlgColumn。那我怎么能这样做呢?
答案 0 :(得分:0)
将您的xaml修改为以下
<DataGrid.Columns>
<DataGridCheckBoxColumn
x:Name="delFlgColumn"
Binding="{Binding Path=DelFlg, NotifyOnTargetUpdated=True, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
Header="Del Flg"
Width="SizeToHeader"
Visibility="Hidden"/>
<DataGridTextColumn
x:Name="ModeFlgColumn"
Header="Mode"
Width="SizeToHeader"
Visibility="Visible"
YourEvent="YourEventMethod"/>
</DataGrid.Columns>
在codebehind中添加此方法
private void YourEventMethod(object sender, YourEventArgs e)
{
// do stuff
}