Slant-shadow Опубликовано 14 октября, 2014 Жалоба Поделиться Опубликовано 14 октября, 2014 <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> Помогите найти ошибку, необходимо по нажатию кнопки, чтобы она меня цвет наполовину, и цвет держался несколько секунд, у меня она просто меняет цвет Цитата Ссылка на комментарий Поделиться на другие сайты Поделиться
Рекомендуемые сообщения
Присоединяйтесь к обсуждению
Вы можете написать сейчас и зарегистрироваться позже. Если у вас есть аккаунт, авторизуйтесь, чтобы опубликовать от имени своего аккаунта.