I just noticed this issue, whenever I select an expander whose parent is a checkbox it triggers the checked/unchecked events even though the checkbox is not checked.
Here is a .gif that shows it occurring. The number in the upper right represents the number of checkboxes checked, I set to to just count up and down whenever a box is checked or unchecked. The counter itself is not the worry here though, just a way to show it happening.
For each checkbox their Checked
and UnChecked
events point to a method of my choosing.
What is causing this to happen, and how do I go about preventing it?
Edit: The XAML
<Expander Loaded="VerifyExpanderLoaded" ExpandDirection="Down" IsExpanded="True" FontSize="14" FontWeight="Bold" Margin="5" BorderThickness="1" BorderBrush="#FF3E3D3D">
<Expander.Header>
<DockPanel RenderTransformOrigin="0.5,0.5" LastChildFill="False" Margin="0" HorizontalAlignment="Stretch">
<TextBlock Text="Verify Caller and Account" DockPanel.Dock="Left" VerticalAlignment="Center" Margin="0"/>
<Button DockPanel.Dock="Right" Margin="1,0" Click="VerifyUncheckAll">
<TextBlock Text="Uncheck All" Margin="1,0" FontSize="12" FontWeight="Normal"/>
</Button>
<Button DockPanel.Dock="Right" Margin="1,0" Click="VerifyCheckAll">
<TextBlock Text="Check All" FontSize="12" FontWeight="Normal" Margin="1,0"/>
</Button>
<TextBlock x:Name="VerifyCheckboxCount" Text="0/0" DockPanel.Dock="Right" VerticalAlignment="Center" FontSize="16" FontWeight="Bold" Margin="0,0,10,0"/>
</DockPanel>
</Expander.Header>
<ListBox Background="{x:Null}" BorderBrush="{x:Null}">
<CheckBox x:Name="Authentication_CallerName_Checkbox" HorizontalAlignment="Center" Margin="10,5,0,0" Grid.ColumnSpan="2" FontSize="12" VerticalAlignment="Center" Checked="VerifyCheckBoxChecked" Unchecked="VerifyCheckBoxChecked">
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center">
<TextBlock Text="Caller's Name" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="14"/>
<StackPanel>
<Expander ExpandDirection="Right" Margin="5,2,0,0" VerticalAlignment="Bottom" HorizontalAlignment="Right" FontSize="14">
<TextBlock Text="Obtain Callers Name " HorizontalAlignment="Center" Margin="0" VerticalAlignment="Center" FontWeight="Normal" FontStyle="Italic">
<Hyperlink x:Name="AuthenticationWikiLink" NavigateUri="[Redacted]" RequestNavigate="ExternalLinks">
Link
</Hyperlink>
</TextBlock>
</Expander>
</StackPanel>
</StackPanel>
</CheckBox>