<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>
时间: 2024-10-07 21:35:49