WPF
中是否有动画标签控件(下面提到的android中的一个)的例子?任何tab/button
控件在按下时会向下箭头设置动画?
这个适用于android: Setting selected TAB with a small triangle below it
答案 0 :(得分:1)
是什么阻止你这样做
<Application.Resources>
<ControlTemplate x:Key="ButtonTemplate1"
TargetType="{x:Type Button}">
<Border
Name="Border"
BorderBrush="Black"
BorderThickness="2"
CornerRadius="2"
Background="#FF2278CF"
TextBlock.Foreground="White">
<Grid>
<ContentPresenter
Margin="{TemplateBinding Padding}"
RecognizesAccessKey="True"
HorizontalAlignment="Center">
</ContentPresenter>
</Grid>
</Border>
</ControlTemplate>
<ControlTemplate x:Key="ButtonTemplate2"
TargetType="{x:Type Button}">
<Border
Name="Border"
BorderBrush="Black"
BorderThickness="2"
CornerRadius="50"
Background="Red"
TextBlock.Foreground="White">
<Grid>
<ContentPresenter
Margin="{TemplateBinding Padding}"
RecognizesAccessKey="True"
HorizontalAlignment="Center">
</ContentPresenter>
</Grid>
</Border>
</ControlTemplate>
<Style TargetType="{x:Type Button}">
<Setter Property="Control.Template" Value="{StaticResource ButtonTemplate1}"></Setter>
<Style.Triggers>
<Trigger Property="Control.IsMouseOver" Value="true">
<Setter Property="Control.Template" Value="{StaticResource ButtonTemplate2}"></Setter>
</Trigger>
</Style.Triggers>
</Style>
</Application.Resources>
在ControlTemplate中,您可以控制任何您想要的形式。
答案 1 :(得分:0)
也许您应该使用触发器。 Trigger Class Styles using triggers in WPF
答案 2 :(得分:0)
我能做到这一点就是混合。这可以自己动画,单击按钮即可触发故事板。这不是完美的答案,但它提出了这个想法。
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ed="http://schemas.microsoft.com/expression/2010/drawing"
mc:Ignorable="d"
x:Class="SilverlightPrototype1Screens.Screen_1"
Width="640" Height="480">
<UserControl.Resources>
<Storyboard x:Name="Storyboard1">
<PointAnimationUsingKeyFrames Storyboard.TargetProperty="(Callout.AnchorPoint)" Storyboard.TargetName="callout">
<EasingPointKeyFrame KeyTime="0" Value="0.254,0.962"/>
<EasingPointKeyFrame KeyTime="0:0:2" Value="0.269,1.385"/>
</PointAnimationUsingKeyFrames>
</Storyboard>
</UserControl.Resources>
<Grid x:Name="LayoutRoot" Background="White">
<ed:Callout x:Name="callout" AnchorPoint="0.277,1.593" CalloutStyle="RoundedRectangle" Fill="#FF737393" FontSize="14.666999816894531" HorizontalAlignment="Left" Height="52" Margin="150,88,0,0" Stroke="Black" VerticalAlignment="Top" Width="130" RenderTransformOrigin="0.5,0.5"/>
</Grid></UserControl>