Note that there are some explanatory texts on larger screens.

plurals
  1. POCheckBox no checked Event when mouse hits content
    primarykey
    data
    text
    <p>I have a question about CheckBox. I don't want the CheckBox to fire the checked event when the user clicks on the content of the CheckBox. I know that I can set IsHitTestVisible = False in the ContentPresenter. </p> <p>At the moment I can't initialize my CheckBox with cb.IsChecked. Any ideas regarding this? Or has anyone a different idea?</p> <p>Thanks in advance.</p> <p>CU soltyr</p> <p>My XAML Code:</p> <pre><code> &lt;Style x:Key="CheckBoxStyle" x:Name="myCheckBoxStyle" TargetType="{x:Type CheckBox}"&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="{x:Type CheckBox}"&gt; &lt;Grid&gt; &lt;Grid.ColumnDefinitions&gt; &lt;ColumnDefinition Width="16" /&gt; &lt;ColumnDefinition Width="Auto" /&gt; &lt;/Grid.ColumnDefinitions&gt; &lt;CheckBox Grid.Column="0" Click="cb_Click"&gt; &lt;/CheckBox&gt; &lt;ContentPresenter Grid.Column="1" Margin="5,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Left" IsHitTestVisible="False" /&gt; &lt;/Grid&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; </code></pre> <p>My C# Code</p> <pre><code>for (int i = 0; i &lt; tcList.Count; i++) { lbi = new ListBoxItem(); tc = (TableContent)tcList[i]; cb = new CheckBox(); cb.Style = (Style)FindResource("CheckBoxStyle"); cb.Content = tc.test1; cb.IsChecked = tc.test2; lbi.Margin = new Thickness(0, 4, 0, 0); lbi.Content = cb; lbi.Selected += new RoutedEventHandler(lbi_Selected); lbi.KeyDown += new KeyEventHandler(lbi_KeyUp); lbi.KeyUp += new KeyEventHandler(lbi_KeyUp); lbTaster.Items.Add(lbi); ht.Add(i, tc.On_Off); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload