ToggleButton doesn't show any state ToggleButton doesn't show any state wpf wpf

ToggleButton doesn't show any state


This is a confirmed defect in WPF. The workaround is to style the control accordingly, although a fix may be considered by the product group. To request a fix, please contact Microsoft Support.


For everybody who want some code to start off with, you can take the code I used to style my controls:

<Application.Resources>        <!-- Toogle button fix (includes custom button + toggle button style) -->        <Style TargetType="{x:Type Button}">            <Setter Property="Background" Value="{StaticResource ButtonNormalBackground}"/>            <Setter Property="BorderBrush" Value="{StaticResource ButtonNormalBorder}"/>            <Setter Property="BorderThickness" Value="1"/>            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>            <Setter Property="HorizontalContentAlignment" Value="Center"/>            <Setter Property="VerticalContentAlignment" Value="Center"/>            <Setter Property="Padding" Value="1"/>            <Setter Property="Template">                <Setter.Value>                    <ControlTemplate TargetType="{x:Type Button}">                        <Border BorderThickness="1" BorderBrush="#FFA4A4A4">                            <Grid>                                <Rectangle x:Name="Rectangle_Background" Fill="#FFEDEDED" />                                <ContentPresenter x:Name="ContentPresenter_Content" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>                            </Grid>                        </Border>                        <ControlTemplate.Triggers>                            <Trigger Property="IsEnabled" Value="false">                                <Setter TargetName="Rectangle_Background" Property="Fill" Value="#f7f7f7"/>                                <Setter TargetName="ContentPresenter_Content" Property="Opacity" Value="0.5"/>                            </Trigger>                            <Trigger Property="IsMouseOver" Value="True">                                <Setter TargetName="Rectangle_Background" Property="Fill" Value="#e0e0e0" />                            </Trigger>                        </ControlTemplate.Triggers>                    </ControlTemplate>                </Setter.Value>            </Setter>        </Style>        <Style TargetType="{x:Type ToggleButton}">            <Setter Property="Background" Value="{StaticResource ButtonNormalBackground}"/>            <Setter Property="BorderBrush" Value="{StaticResource ButtonNormalBorder}"/>            <Setter Property="BorderThickness" Value="1"/>            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>            <Setter Property="HorizontalContentAlignment" Value="Center"/>            <Setter Property="VerticalContentAlignment" Value="Center"/>            <Setter Property="Padding" Value="1"/>            <Setter Property="Template">                <Setter.Value>                    <ControlTemplate TargetType="{x:Type ToggleButton}">                        <Border BorderThickness="1" BorderBrush="#FFA4A4A4">                            <Grid>                                <Rectangle x:Name="Rectangle_Background" Fill="#FFEDEDED" />                                <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>                            </Grid>                        </Border>                        <ControlTemplate.Triggers>                            <Trigger Property="IsEnabled" Value="false">                                <Setter TargetName="Rectangle_Background" Property="Fill" Value="#ADADAD"/>                            </Trigger>                            <Trigger Property="IsMouseOver" Value="True">                                <Setter TargetName="Rectangle_Background" Property="Fill" Value="#e0e0e0" />                            </Trigger>                            <Trigger Property="IsChecked" Value="true">                                <Setter Property="Fill" TargetName="Rectangle_Background" Value="#bee6fd"/>                            </Trigger>                        </ControlTemplate.Triggers>                    </ControlTemplate>                </Setter.Value>            </Setter>        </Style>    </Application.Resources>