Jump to content
СофтФорум - всё о компьютерах и не только

Изменение кнопки


Recommended Posts

<Window x:Class="WpfApplication12.MainWindow"        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"        Title="MainWindow" Height="350" Width="525">    <Window.Resources>            <ControlTemplate x:Key="TemplateB" TargetType="Button">            <Border BorderBrush="Orange" BorderThickness="3" CornerRadius="2" Name="bor"                  TextBlock.Foreground="Red">                <Border.Background>                    <LinearGradientBrush>                        <GradientStopCollection>                            <GradientStop Offset="0" Color="Yellow"></GradientStop>                            <GradientStop Offset="1" Color="Green"></GradientStop>                        </GradientStopCollection>                    </LinearGradientBrush>                </Border.Background>                <ContentPresenter RecognizesAccessKey="True" Margin="{TemplateBinding Padding}"></ContentPresenter>            </Border>            <ControlTemplate.Triggers>                <Trigger Property="IsMouseOver" Value="true">                    <Setter TargetName="bor" Property="Background" Value="Green"></Setter>                </Trigger>                <!--Trigger Property="IsPressed" Value="True">                    <Setter TargetName="bor" Property="Background" Value="Red"></Setter>                </Trigger-->            </ControlTemplate.Triggers>        </ControlTemplate>        <ControlTemplate x:Key="TemplateA" TargetType="Button">            <Border Name="bor"                  TextBlock.Foreground="Red">                <Border.Background>                    <LinearGradientBrush>                        <GradientStopCollection>                            <GradientStop Offset="0" Color="Yellow"></GradientStop>                            <GradientStop Offset="1" Color="Green"></GradientStop>                        </GradientStopCollection>                    </LinearGradientBrush>                </Border.Background>                <ContentPresenter RecognizesAccessKey="True" Margin="{TemplateBinding Padding}"></ContentPresenter>                <Border.Triggers>                    <EventTrigger RoutedEvent="Border.MouseDown">                        <EventTrigger.Actions>                            <BeginStoryboard>                                <Storyboard>                                    <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Button.Background).(SolidColorBrush.Color)">                                        <LinearColorKeyFrame KeyTime="00:00:00" Value="Red"></LinearColorKeyFrame>                                    </ColorAnimationUsingKeyFrames>                                </Storyboard>                            </BeginStoryboard>                        </EventTrigger.Actions>                    </EventTrigger>                </Border.Triggers>            </Border>            <ControlTemplate.Triggers>                <Trigger Property="IsMouseOver" Value="true">                    <Setter TargetName="bor" Property="Background" Value="Green"></Setter>                </Trigger>                <Trigger Property="IsPressed" Value="True">                <Setter TargetName="bor"  Property="Background" Value="Red"></Setter>                </Trigger>            </ControlTemplate.Triggers>            </ControlTemplate>    </Window.Resources>    <Button Margin="10" Width="130" Height="130" Template="{StaticResource TemplateB}">    <Button Margin="65,0,0,0" Width="65" Height="130" Template="{StaticResource TemplateA}"></Button>    </Button></Window>

Помогите найти ошибку, необходимо по нажатию кнопки, чтобы она меня цвет наполовину, и цвет держался несколько секунд, у меня она просто меняет цвет

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...