ContentTemplate doesn't apply to Button
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 9.6k
- Forks
- 1k
- PR merge metrics
- No merged PRs in 30d
Description
Describe the bug
I've implement style for Button that wrap the content with ViewBox with overriding ContentTemplate property
But the ContentTemplate doesn't apply to Button's content
` <Style TargetType="Button" BasedOn="{StaticResource DefaultButtonStyle}">
<Setter Property="HorizontalContentAlignment" Value="Stretch"></Setter>
<Setter Property="VerticalContentAlignment" Value="Stretch"></Setter>
<Setter Property="Padding" Value="5"></Setter>
<Setter Property="Height" Value="45"></Setter>
<Setter Property="Width" Value="45"></Setter>
<Setter Property="RenderTransformOrigin" Value="0.5,0.5"></Setter>
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<Viewbox StretchDirection="Both" Stretch="Uniform" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
<ContentPresenter
VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
</ContentPresenter>
</Viewbox>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>`
To Reproduce
Override the "DefaultButtonStyle" style and set ContentTemplate
Expected behavior
The ContentTemplate must be applied to content
Screenshots
No response
OS version
Windows 10 x64
.NET version
.Net 7
WPF-UI NuGet version
3.0.0-preview.2
Additional context
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the XAML example with Button, DefaultButtonStyle, and ContentTemplate in a WPF UI application using WPF-UI 3.0.0-preview.2 on Windows. Trace the Button content presentation behavior and verify that the ViewBox template is applied to the content; the issue names no source file or test, so add focused coverage where the behavior is implemented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100