Reputation: 17
When I clicked toggle button it selects each and every checkbox. When I click the toggle button again, it will uncheck every checkbox.
If I clicked individual checkbox, it selects all checkbox. Is it possible to select manually individual checkbox without clicking toggle button?
<CheckBox Uid="checkbox1" Name="checkbox1" Checked="CheckBox_Checked" Unchecked="CheckBox_UnChecked" IsChecked="{Binding ElementName=button,Path=IsChecked}">
<Image Source="{Binding Path=UriSource}" Stretch="Fill" Width="100" Height="120" />
</CheckBox>
<ToggleButton x:Name="button" Content="Select/Unselect" Click="ToggleButton_Click" HorizontalAlignment="Left" Margin="54,545,0,0" VerticalAlignment="Top" Width="115" Height="57" RenderTransformOrigin="0.986,1.365" />
Upvotes: 0
Views: 395
Reputation: 1628
You can achieve it with the help of following code
<StackPanel Orientation="Horizontal">
<CheckBox Name="checkbox1"
Content="Checkbox 1"
Margin="5"
IsChecked="{Binding ElementName=button,Path=IsChecked,Mode=OneWay}"></CheckBox>
<CheckBox Name="checkbox2"
Content="Checkbox 2"
Margin="5"
IsChecked="{Binding ElementName=button,Path=IsChecked,Mode=OneWay}"></CheckBox>
<ToggleButton x:Name="button"
Content="Select/Unselect"
Width="Auto"
Height="25"
Margin="5"
VerticalAlignment="Top" />
</StackPanel>
You need to set binding mode of check boxes to OneWay as shown in above code
Upvotes: 1