复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34<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触发器样式内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复