wpf icon indicating copy to clipboard operation
wpf copied to clipboard

ToggleButton doesn't use ContentTemplate in Fluent style

Open bwood4 opened this issue 3 months ago • 0 comments

Description

The DefaultToggleButtonStyle doesn't bind ContentTemplate to the ContentPresenter like DefaultButtonStyle does in the Fluent theme (I haven't looked at other themes).

Reproduction Steps

Create a window in a WPF app configured to use the Fluent theme with the following code:

<Window ...>
  <Window.Resources>
    <DataTemplate x:Key="ReplaceTextTemplate">
      <TextBlock Text="Replaced text" />
    </DataTemplate>
    <Style TargetType="Button" BasedOn="{StaticResource DefaultButtonStyle}">
      <Setter Property="ContentTemplate" Value="{StaticResource ReplaceTextTemplate}" />
    </Style>
    <Style TargetType="ToggleButton" BasedOn="{StaticResource DefaultToggleButtonStyle}">
      <Setter Property="ContentTemplate" Value="{StaticResource ReplaceTextTemplate}" />
    </Style>
  </Window.Resources>

  <StackPanel>
    <Button Content="Hello" />
    <ToggleButton Content="Hello" />
  </StackPanel>

</Window>

Expected behavior

The content in the Button and ToggleButton should match and say "Replaced text".

Actual behavior

The Button says "Replaced text", but the ToggleButton still says "Hello".

Regression?

No response

Known Workarounds

No response

Impact

It makes configuring the ToggleButton more difficult and is inconsistent with the behavior of Button.

Configuration

No response

Other information

No response

bwood4 avatar Sep 05 '25 15:09 bwood4