Into Tag property you can put reference to parent element (in your case it's StackPanel) and in code-behind you can find element by using FindName method.
XAML:
<DataTemplate x:Key="datatemp">
<StackPanel x:Name="stackPanel" Orientation="Horizontal" Width="200" >
<TextBlock Text="{Binding VmName}" Width="129" Visibility="Visible" />
<CheckBox Name="cb" Tag="{Binding ElementName=stackPanel}" IsThreeState="False" Checked="off_chek_select" IsChecked="{Binding IsCheck, Mode=TwoWay}" Margin="6,0,18,6" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
<CheckBox Name="cb1" Tag="{Binding ElementName=stackPanel}" IsThreeState="False" Checked="ins_chek_select" IsChecked="{Binding IsCheck1, Mode=TwoWay}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
</StackPanel>
</DataTemplate>
Code-behind:
private void off_chek_select(object sender, RoutedEventArgs e)
{
var cbSender = sender as CheckBox;
if (cbSender != null)
{
var stackPanel = cbSender.Tag as StackPanel;
if (stackPanel != null)
{
var cb1 = stackPanel.FindName("cb1") as CheckBox;
if (cb1 != null)
{
cb1.IsChecked = !cbSender.IsChecked;
}
}
}
}
private void ins_chek_select(object sender, RoutedEventArgs e)
{
var cbSender = sender as CheckBox;
if (cbSender != null)
{
var stackPanel = cbSender.Tag as StackPanel;
if (stackPanel != null)
{
var cb = stackPanel.FindName("cb") as CheckBox;
if (cb != null)
{
cb.IsChecked = !cbSender.IsChecked;
}
}
}
}
If you have multiple choices and only one should be selected at the time you could use RadioButton (msdn).
<UserControl.Resources>
<DataTemplate x:Key="datatemp">
<StackPanel Orientation="Horizontal" Width="200" >
<TextBlock Text="{Binding VmName}" Width="129" Visibility="Visible" />
<RadioButton Name="cb" IsThreeState="False" IsChecked="{Binding IsCheck, Mode=TwoWay}" Margin="6,0,18,6" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
<RadioButton Name="cb1" IsThreeState="False" IsChecked="{Binding IsCheck1, Mode=TwoWay}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
</StackPanel>
</DataTemplate>
</UserControl.Resources>