У меня есть приложение, которое отображает мой пользовательский значок кнопки.Я пытаюсь сделать эту кнопку более изощренной!
Я пытаюсь изменить цвет текстового поля переднего плана при обнаружении нажатия кнопки триггера mouseOver.Это возможно ?Я не могу это сделать ...
Кроме того, я хотел бы иметь такой же эффект на цвет границы.Я полагаю, это так же.
Спасибо!
<Style x:Key="Triggers" TargetType="TextBox">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property = "Foreground" Value="White"/>
</Trigger>
</Style.Triggers>
</Style>
<Style TargetType="{x:Type Button}">
<Setter Property="FontFamily" Value="Calibri"/>
<Setter Property="FontSize" Value="13"/>
<Setter Property="Cursor" Value="Hand"/>
<Setter Property="Height" Value="80"/>
<Setter Property="Width" Value="80"/>
<Setter Property="Foreground">
<Setter.Value>
<SolidColorBrush Opacity="1" Color="White"/>
</Setter.Value>
</Setter>
<Setter Property="Background" >
<Setter.Value>
<SolidColorBrush Opacity="1" Color="#FFE0E0E0" />
</Setter.Value>
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border x:Name="border" Margin="5"
SnapsToDevicePixels="True"
CornerRadius="5" BorderBrush="White" BorderThickness="1"
Background="{TemplateBinding Background}">
<StackPanel Height="Auto" Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Center">
<StackPanel.Background>
<SolidColorBrush Color="WhiteSmoke" Opacity="0.05"/>
</StackPanel.Background>
<Image Source="{Binding Path=ImageSource}" Width="30" Height="30" Margin="0,5,0,0" />
<TextBlock Text="{Binding Path=TextBlockText}" HorizontalAlignment="Center" Foreground="#575757" VerticalAlignment="Center" FontSize="12" FontFamily="Calibri" MaxWidth="78" MinWidth="78" MinHeight="20" TextAlignment="Center" TextWrapping="Wrap" Margin="0,2,0,0"/>
</StackPanel>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Trigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<ColorAnimation To="#FFFBFBFB"
Storyboard.TargetProperty="(Control.Background).(SolidColorBrush.Color)"
FillBehavior="HoldEnd" Duration="0:0:0.25" AutoReverse="False" RepeatBehavior="1x"/>
</Storyboard>
</BeginStoryboard>
</Trigger.EnterActions>
<Trigger.ExitActions>
<BeginStoryboard>
<Storyboard>
<ColorAnimation
Storyboard.TargetProperty="(Control.Background).(SolidColorBrush.Color)"
FillBehavior="HoldEnd" Duration="0:0:0.25" AutoReverse="False" RepeatBehavior="1x"/>
</Storyboard>
</BeginStoryboard>
</Trigger.ExitActions>
</Trigger>
<Trigger Property="IsPressed" Value="true">
<Trigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<ColorAnimation To="#FF5D5D5D"
Storyboard.TargetProperty="(Control.Background).(SolidColorBrush.Color)"
FillBehavior="HoldEnd" Duration="0:0:0.00" AutoReverse="False" RepeatBehavior="1x"/>
</Storyboard>
</BeginStoryboard>
</Trigger.EnterActions>
<Trigger.ExitActions>
<BeginStoryboard>
<Storyboard>
<ColorAnimation
Storyboard.TargetProperty="(Control.Background).(SolidColorBrush.Color)"
FillBehavior="HoldEnd" Duration="0:0:0.00" AutoReverse="False" RepeatBehavior="1x"/>
</Storyboard>
</BeginStoryboard>
</Trigger.ExitActions>
</Trigger>
</Style.Triggers>
</Style>