概述
<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>
转载于:https://www.cnblogs.com/xiepengtest/p/4178445.html
最后
以上就是动听大象为你收集整理的Button触发器样式的全部内容,希望文章能够帮你解决Button触发器样式所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复