Skip to content

Commit

Permalink
Fix AccentButton styles
Browse files Browse the repository at this point in the history
  • Loading branch information
WamWooWam committed Nov 25, 2024
1 parent 4e27977 commit 3bec07e
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 3 deletions.
3 changes: 1 addition & 2 deletions UniSky/Pages/LoginPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,7 @@

<Button Content="Login"
TabIndex="2"
Style="{ThemeResource AccentButtonStyle}"
Padding="{ThemeResource ButtonPadding}"
Style="{ThemeResource AccentButtonStyle}"
Grid.Column="2"
HorizontalAlignment="Right"
MinWidth="100"
Expand Down
1 change: 0 additions & 1 deletion UniSky/Pages/ProfilePage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@

<Button x:Name="FollowButton"
Style="{ThemeResource AccentButtonStyle}"
Padding="{ThemeResource ButtonPadding}"
Grid.Column="1"
Grid.RowSpan="2"
VerticalAlignment="Center">
Expand Down
87 changes: 87 additions & 0 deletions UniSky/Templates/ButtonStyles.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -325,4 +325,91 @@
</Setter>
</Style>

<Style x:Key="AccentButtonStyle" TargetType="Button">
<Setter Property="Foreground" Value="{ThemeResource AccentButtonForeground}" />
<Setter Property="Background" Value="{ThemeResource AccentButtonBackground}" />
<Setter Property="BorderBrush" Value="{ThemeResource AccentButtonBorderBrush}" />
<Setter Property="Padding" Value="{ThemeResource ButtonPadding}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<ContentPresenter x:Name="ContentPresenter"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
ContentTransitions="{TemplateBinding ContentTransitions}"
CornerRadius="{TemplateBinding CornerRadius}"
Padding="{TemplateBinding Padding}"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
AutomationProperties.AccessibilityView="Raw">

<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal">

<Storyboard>
<PointerUpThemeAnimation Storyboard.TargetName="ContentPresenter" />
</Storyboard>
</VisualState>

<VisualState x:Name="PointerOver">

<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Background">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource AccentButtonBackgroundPointerOver}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="BorderBrush">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource AccentButtonBorderBrushPointerOver}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource AccentButtonForegroundPointerOver}" />
</ObjectAnimationUsingKeyFrames>
<PointerUpThemeAnimation Storyboard.TargetName="ContentPresenter" />
</Storyboard>
</VisualState>

<VisualState x:Name="Pressed">

<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Background">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource AccentButtonBackgroundPressed}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="BorderBrush">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource AccentButtonBorderBrushPressed}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource AccentButtonForegroundPressed}" />
</ObjectAnimationUsingKeyFrames>
<PointerDownThemeAnimation Storyboard.TargetName="ContentPresenter" />
</Storyboard>
</VisualState>

<VisualState x:Name="Disabled">

<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Background">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource AccentButtonBackgroundDisabled}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="BorderBrush">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource AccentButtonBorderBrushDisabled}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource AccentButtonForegroundDisabled}" />
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>

</VisualStateGroup>

</VisualStateManager.VisualStateGroups>
</ContentPresenter>

</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

</ResourceDictionary>

0 comments on commit 3bec07e

Please sign in to comment.