Исправил нажатие кнопки.

This commit is contained in:
maksim 2024-11-26 22:52:43 +04:00
parent ca42b880f1
commit 74f1fda7c7
2 changed files with 44 additions and 12 deletions

View File

@ -8,18 +8,21 @@
<Setter.Value>
<ControlTemplate TargetType="Button">
<Grid>
<!-- Тень кнопки -->
<Border Background="{TemplateBinding Background}"
CornerRadius="15"
BorderBrush="Transparent"
BorderThickness="0"
x:Name="ButtonBorder">
CornerRadius="15"
BorderBrush="Transparent"
BorderThickness="0"
x:Name="ButtonBorder">
<Border.Effect>
<DropShadowEffect Color="Black" BlurRadius="10" ShadowDepth="2" Opacity="0.4" />
</Border.Effect>
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" />
</Border>
<Grid.RenderTransform>
<ScaleTransform x:Name="scaleTransform" ScaleX="1" ScaleY="1" />
</Grid.RenderTransform>
</Grid>
<ControlTemplate.Triggers>
<!-- Анимация цвета при наведении -->
<Trigger Property="IsMouseOver" Value="True">
@ -27,8 +30,8 @@
<BeginStoryboard>
<Storyboard>
<ColorAnimation Storyboard.TargetName="ButtonBorder"
Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)"
To="#0066CC" Duration="0:0:0.2" />
Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)"
To="#0066CC" Duration="0:0:0.2" />
</Storyboard>
</BeginStoryboard>
</Trigger.EnterActions>
@ -36,15 +39,16 @@
<BeginStoryboard>
<Storyboard>
<ColorAnimation Storyboard.TargetName="ButtonBorder"
Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)"
To="#004890" Duration="0:0:0.2" />
Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)"
To="#004890" Duration="0:0:0.2" />
</Storyboard>
</BeginStoryboard>
</Trigger.ExitActions>
</Trigger>
<!-- Анимация сжатия при нажатии -->
<!-- Плавная анимация сжатия и тени при нажатии -->
<Trigger Property="IsPressed" Value="True">
<Setter Property="RenderTransformOrigin" Value="0.5,0.5" />
<Setter Property="RenderTransform" TargetName="ButtonBorder">
<Setter.Value>
<ScaleTransform ScaleX="0.95" ScaleY="0.95" />
@ -55,6 +59,30 @@
<DropShadowEffect Color="Black" BlurRadius="15" ShadowDepth="0" Opacity="0.6" />
</Setter.Value>
</Setter>
<Trigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetName="scaleTransform"
Storyboard.TargetProperty="ScaleX"
To="1.0" Duration="0:0:0.1" />
<DoubleAnimation Storyboard.TargetName="scaleTransform"
Storyboard.TargetProperty="ScaleY"
To="1.0" Duration="0:0:0.1" />
</Storyboard>
</BeginStoryboard>
</Trigger.EnterActions>
<Trigger.ExitActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetName="scaleTransform"
Storyboard.TargetProperty="ScaleX"
To="0.95" Duration="0:0:0.2" />
<DoubleAnimation Storyboard.TargetName="scaleTransform"
Storyboard.TargetProperty="ScaleY"
To="0.95" Duration="0:0:0.2" />
</Storyboard>
</BeginStoryboard>
</Trigger.ExitActions>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
@ -62,6 +90,7 @@
</Setter>
</Style>
<!-- Стиль для закругленного TextBox -->
<Style x:Key="RoundedTextBoxStyle" TargetType="TextBox">
<Setter Property="Template">

View File

@ -1,7 +1,10 @@
<Window x:Class="EmployeeManagmentView.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Отдел кадров УлГТУ" Height="450" Width="800" Background="#0D2D4F">
Title="Отдел кадров УлГТУ" Height="450" Width="800" Background="#0D2D4F"
MinWidth="400" MinHeight="300"
MaxWidth="{Binding Source={x:Static SystemParameters.PrimaryScreenWidth}}"
MaxHeight="{Binding Source={x:Static SystemParameters.PrimaryScreenHeight}}">
<Grid>