关闭

透明BUTTON 模板 WPF

标签: buttonwpfsetter
1121人阅读 评论(2) 收藏 举报
分类:

  <ControlTemplate x:Key="NavTemp" TargetType="{x:Type Button}">
        <Grid Width="{TemplateBinding Width}" Background="{TemplateBinding Background}"
      Height="80" ClipToBounds="True">
            <Label Content="{TemplateBinding Content}" Margin="10,20,0,0"/>
        </Grid>
    </ControlTemplate>

 

 

="{StaticResource ShopBtnBrush}"  这个东西就是图片 随意替换

 

<ControlTemplate x:Key="HomeBtnTemplate" TargetType="{x:Type Button}">
        <Grid Width="{TemplateBinding Width}" Background="{TemplateBinding Background}"
      Height="{TemplateBinding Height}" ClipToBounds="True">
            <Rectangle x:Name="glassCube" HorizontalAlignment="Stretch"
        VerticalAlignment="Stretch" Opacity="1"
        Fill="{StaticResource ShopBtnBrush}"  RenderTransformOrigin="0.5,0.5"
                        RadiusX="10" RadiusY="10">
                <Rectangle.RenderTransform>
                    <TransformGroup>
                        <ScaleTransform />
                    </TransformGroup>
                </Rectangle.RenderTransform>
            </Rectangle>
        </Grid>

        <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Rectangle.Opacity" Value="1"       TargetName="glassCube" />
            </Trigger>
            <Trigger Property="IsFocused" Value="true">
                <Setter Property="Rectangle.Opacity" Value="1"   TargetName="glassCube" />
            </Trigger>
            <EventTrigger RoutedEvent="Mouse.MouseEnter">
                <EventTrigger.Actions>
                    <BeginStoryboard Name="mouseEnterBeginStoryboard">
                        <Storyboard AutoReverse="True">
                            <DoubleAnimation Storyboard.TargetName="glassCube"
          Storyboard.TargetProperty=
          "(Rectangle.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)"
          By="0.03" Duration="0:0:0.2" />
                            <DoubleAnimation
        Storyboard.TargetName="glassCube"
          Storyboard.TargetProperty=
          "(Rectangle.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"
          By="0.03" Duration="0:0:0.2" />
                        </Storyboard>
                    </BeginStoryboard>
                </EventTrigger.Actions>
            </EventTrigger>
            <EventTrigger RoutedEvent="Mouse.MouseLeave">
                <EventTrigger.Actions>
                </EventTrigger.Actions>
            </EventTrigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

 

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:69425次
    • 积分:1233
    • 等级:
    • 排名:千里之外
    • 原创:38篇
    • 转载:3篇
    • 译文:4篇
    • 评论:50条