Window Button Style
See original GitHub issueDescribe the bug
Here are some findings, when I try to put buttons in resource dictionary for the window:
- when i try to use the system command like below, the window button cannot be clicked anymore (double clike, the window will be maximized or normalized)
<Setter Property="Command"
Value="{Binding Source={x:Static SystemCommands.MinimizeWindowCommand}}" />
- I try to apply the style below to window button, the IsPressed trigger works as expected, but the IsMouseOver trigger doesn’t work
<Style x:Key="WindowTitleButtonStyle"
TargetType="{x:Type Button}">
<Setter Property="Focusable"
Value="False" />
<Setter Property="Background"
Value="#32FFFFFF" />
<Setter Property="Width"
Value="36" />
<Setter Property="HorizontalContentAlignment"
Value="Center" />
<Setter Property="VerticalContentAlignment"
Value="Center" />
<!--<Setter Property="WindowChrome.IsHitTestVisibleInChrome"
Value="True" />-->
<Setter Property="IsTabStop"
Value="False" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Grid x:Name="LayoutRoot"
Background="Transparent">
<Rectangle x:Name="ButtonBackground"
Fill="Yellow"
Opacity="0" />
<Border x:Name="ButtonBorder"
SnapsToDevicePixels="True">
<ContentPresenter x:Name="TitileButtonContentPresenter"
Focusable="False"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
Margin="{TemplateBinding Padding}"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver"
Value="True">
<Setter Property="Opacity"
Value="1"
TargetName="ButtonBackground" />
</Trigger>
<Trigger Property="IsPressed"
Value="True">
<Setter Property="Opacity"
Value="0.6"
TargetName="ButtonBackground" />
</Trigger>
<Trigger Property="IsEnabled"
Value="False">
<Setter TargetName="TitileButtonContentPresenter"
Property="Opacity"
Value="0.5" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
and here are codes for applying the styles:
<UniformGrid Grid.Column="2"
Columns="3">
<Button Content=" - "
Style="{StaticResource PART_WindowButtonMinimizeStyle}"
tcBehaviors:NonClientControlProperties.HitTestResult="MINBUTTON"
tcBehaviors:NonClientControlProperties.ClickStrategy="MouseEvent" />
<Button Style="{StaticResource PART_WindowButtonMaximizeStyle}"
IsEnabled="{Binding IsEnabled, ElementName=MaximizeButton}"
tcBehaviors:NonClientControlProperties.HitTestResult="MAXBUTTON"
tcBehaviors:NonClientControlProperties.ClickStrategy="MouseEvent" />
<Button Style="{StaticResource WindowTitleButtonStyle}"
tcBehaviors:NonClientControlProperties.HitTestResult="CLOSE"
tcBehaviors:NonClientControlProperties.ClickStrategy="MouseEvent" />
</UniformGrid>
It is acceptable for me to give up the system command. What I can try to fix the mouseover problem?
Thanks, Tiger
Steps to reproduce
Expected behavior
Actual behavior
Environment
ControlzEx version: v6.x.x
Windows build number: Win11
Visual Studio: 2022
Target Framework: .Net 4.8
Screenshots
Issue Analytics
- State:
- Created a year ago
- Comments:5
Top Results From Across the Web
Button Styles (Winuser.h) - Win32 apps
Specifies a combination of button styles. If you create a button using the BUTTON class with the CreateWindow or CreateWindowEx function, ...
Read more >Other Window Styles for Button Controls
The following window style options are available for button controls (check box, radio button group, push button, and group box controls).
Read more >Windows OS Button Style CSS
It's quite difficult to style a button exactly like that, and in a usable scalable format. An alternative is to simulate an HTML...
Read more >How to change Windows 10 button style?
How to change button style like on the higher pic? Mine is on lower pic. Its much cleaner and edges are thinner.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments