码迷,mamicode.com
首页 > 其他好文 > 详细

Button触发器样式

时间:2014-12-22 17:52:17      阅读:186      评论:0      收藏:0      [点我收藏+]

标签:

<Window x:Class="WpfApplication9.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>
        <Style x:Key="NewFolderButtonStyle" TargetType="{x:Type Button}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <Grid x:Name="ContentContainer">
                            <!--设置背景-->
                            <Image Name="IMG_BK" Stretch="Fill"  Source="Image/2.png"/>
                            <Image Stretch="None" Margin="5"  Source="/WpfApplication9;component/Image/fold.png" VerticalAlignment="Center" HorizontalAlignment="Left"></Image>
                            <TextBlock Margin="10 0 0 0" VerticalAlignment="Center" HorizontalAlignment="Center">新建文件夹</TextBlock>
                        </Grid>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsMouseOver" Value="true">
                                <Setter Property="Source" TargetName="IMG_BK" Value="Image/1.png"/>
                            </Trigger>
                            <Trigger Property="IsPressed" Value="true">
                                <Setter Property="Source" TargetName="IMG_BK" Value="Image/1.png"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </Window.Resources>
    <Grid>
        <Button Foreground="Black" Height="31" HorizontalAlignment="Left" Margin="141,174,0,0" Name="button1" VerticalAlignment="Top" Width="112" Style="{DynamicResource NewFolderButtonStyle}"/>
    </Grid>
</Window>

 

 

Button触发器样式

标签:

原文地址:http://www.cnblogs.com/xiepengtest/p/4178445.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!