Skip to content

ToggleButton doesn't use ContentTemplate in Fluent style #11090

@bwood4

Description

@bwood4

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions