I have 4 checkboxes in the datagrid I want to set ischecked = false them when a checkbox is activated Due to the use of datatemplate, I do not have access to the use of name controls
Using a sender, I can only access one control at a time But I want to turn off 3 checkboxes and activate a checkbox
this is my template:
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel Orientation="Vertical" Margin="5" HorizontalAlignment="Right">
<Metro:MetroSwitch Checked="chk_Checked" Tag="exc" Margin="0,2" Name="chkExcelent">خیلی خوب</Metro:MetroSwitch>
<Metro:MetroSwitch Checked="chk_Checked" Tag="good" Margin="0,2" Name="chkGood">خوب</Metro:MetroSwitch>
<Metro:MetroSwitch Checked="chk_Checked" Tag="notbad" Margin="0,2" Name="chkNotBad">قابل قبول</Metro:MetroSwitch>
<Metro:MetroSwitch Checked="chk_Checked" Tag="bad" Name="chkBad">نیاز به تلاش بیشتر</Metro:MetroSwitch>
</StackPanel>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
and this is my sender
private void chk_Checked(object sender, RoutedEventArgs e)
{
switch ((sender as Arthas.Controls.Metro.MetroSwitch).Tag.ToString())
{
case "exc": Console.WriteLine("exc"); break;
case "good": Console.WriteLine("ggg"); break;
case "notbad": Console.WriteLine("nb"); break;
case "bad": Console.WriteLine("bad"); break;
}
}
Aucun commentaire:
Enregistrer un commentaire