WPF Radio IsChecked does not work

I have two switches, and I want one of them to be selected by default. I added IsChecked="true", but it does not work. I also tried installing it in the loading window.

But when I click the second option, and then select the first option, everything works fine.

It just does not appear on first boot.

<StackPanel Orientation="Vertical" Margin="0 3 0 0" Height="55">
    <RadioButton IsChecked="True" Padding="1 1 0 10" Name="AutoSaveRadioButton">
        <TextBlock Foreground="Black">Auto Save Test File</TextBlock>
    </RadioButton>
    <RadioButton Margin="0 1 0 0" Padding="1 1 3 1" Name="SaveFileTogetherRadioButton">
        <TextBlock Foreground="Black">Save Test File &amp; <LineBreak /> output file together</TextBlock>
    </RadioButton>
</StackPanel>
+4
source share
1 answer

Assuming the theme you are using is this , this seems like a bug with the theme. The line Triggeron line 687 is triggered only when the property IsCheckedchanges to False, but the initial state of the template has not been checked.

, :

<Trigger Property="IsChecked" Value="True">
    <Trigger.ExitActions>
        <BeginStoryboard Storyboard="{StaticResource CheckedOff}" />
    </Trigger.ExitActions>
    <Trigger.EnterActions>
        <BeginStoryboard Storyboard="{StaticResource CheckedOn}" />
    </Trigger.EnterActions>
</Trigger>
+4

Source: https://habr.com/ru/post/1526960/


All Articles