WPFにて動的にタブを生成し、そのタブ内にそれぞれ1つずつチェックBOXを生成する画面を作っています。
チェックを入れたチェックBOX以外のチェックを外したいのですが、”IsChecked”を使うコントロール(以下ソースのxxx)に何を指定すればよいのかわからず、困っています。
アドバイスお願い致します。
<補足>
VS2010、.net4.0の環境です。
private void Checked(object sender, RoutedEventArgs e)
{ // チェックイベント処理
System.Windows.Controls.CheckBox chkObj = (System.Windows.Controls.CheckBox)sender;
for (タブ数分ループする)
{
// 全てのチェックBOXからチェックを外す処理を入れたい
xxx.IsChecked = false; // ”xxx”になにを入れればよいのかがわかりません。
}
chkObj.IsChecked = true; // チェック操作したチェックBOXにチェックを入れる
}
<XAML抜粋>
<TabControl x:Name="TabControl" Margin="50,15,0,15" ItemsSource="{Binding TabPanels}">
<TabControl.ContentTemplate>
<DataTemplate>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<ItemsControl Grid.Row="0" VerticalAlignment="Top" ItemsSource="{Binding TabButtons}" Margin="{Binding TabCtrlMg}">
~~~中略~~~
</ItemsControl>
<ItemsControl Grid.Row="1" VerticalAlignment="Bottom" ItemsSource="{Binding TabCk}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<CheckBox IsChecked="{Binding IsChecked}" Checked="Checked" Unchecked="UnChecked" HorizontalAlignment="Left" d:DataContext="{Binding CheckKey}">
<CheckBox.LayoutTransform>
<ScaleTransform ScaleX="3" ScaleY="3"/>
</CheckBox.LayoutTransform>
</CheckBox>
</DataTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Margin="35,0,0,5"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
</Grid>
</DataTemplate>
</TabControl.ContentTemplate>
</TabControl>