0

中是否有动画选项卡控件的示例(下面提到的 android 中的一个)WPFtab/button按下时动画到向下箭头的任何控件?

这个适用于android: 设置选定的TAB,下面有一个小三角形

4

3 回答 3

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 中,您可以使您的控件成为您想要的任何形式。

于 2013-04-02T07:17:36.553 回答
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>
于 2013-04-02T08:18:22.770 回答
0

也许您应该使用触发器。 使用 WPF 中的触发器触发类样式

于 2013-04-02T06:51:02.563 回答