FinallyInSeattle

I have a RadioButton control that has a style trigger that changes the border & background color when IsChecked becomes true. When I execute code in the Checked event, it appears that, while IsChecked = true, the style trigger hasn't occurred yet. How can I force the trigger update - I'd like to see the visual change before the logic in the Checked event does a data access call



Re: Windows Presentation Foundation (WPF) Forcing a style trigger to update

Luc Vo Van

I'm not sure, but I don't think you can do that, maybe you could declare the "IsChecked style" in your resources, and apply it manually in your Checked event

Luc





Re: Windows Presentation Foundation (WPF) Forcing a style trigger to update

Yi-Lun Luo - MSFT

Hello, the problem maybe, RadioButtonĄŻs Background only affects the small circle, not its Content. So the change may be difficult to notice. You can instead set a Background for the BulletDecorator in ControlTemplate:

<ControlTemplate TargetType="{x:Type RadioButton}">

<BulletDecorator x:Name="bulletDecorator" Background="#FFFF0000">

<BulletDecorator.Bullet>

<Microsoft_Windows_Themes:BulletChrome Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" IsChecked="{TemplateBinding IsChecked}" IsRound="true" RenderMouseOver="{TemplateBinding IsMouseOver}" RenderPressed="{TemplateBinding IsPressed}"/>

</BulletDecorator.Bullet>

<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" RecognizesAccessKey="True"/>

</BulletDecorator>

<ControlTemplate.Triggers>

<Trigger Property="IsChecked" Value="True">

<Setter Property="Background" TargetName="bulletDecorator" Value="#FF0000FF"/>

</Trigger>

</ControlTemplate.Triggers>

</ControlTemplate>






Re: Windows Presentation Foundation (WPF) Forcing a style trigger to update

FinallyInSeattle

Thanks for the assistance. However, I've re-styled the radio button such that changing the background color does highlight the entire item.





Re: Windows Presentation Foundation (WPF) Forcing a style trigger to update

Ben Carter - MSFT

You could call Dispatcher.BeginInvoke and post a callback. That should get you to a point after all the style updates have occurred. Then, you can perform your desired operations.

Ben