xaml – 按钮样式看起来像应用程序栏按钮
发布时间:2020-12-14 04:38:40 所属栏目:Windows 来源:网络整理
导读:是否可以通过更改样式将xaml按钮标记设置为应用程序栏按钮?以及如何做到这一点. 解决方法 希望这可以帮助. Page.Resources Style x:Key="RoundedButton" TargetType="Button" Setter Property="Template" Setter.Value ControlTemplate TargetType="Button"
是否可以通过更改样式将xaml按钮标记设置为应用程序栏按钮?以及如何做到这一点.
解决方法
希望这可以帮助.
<Page.Resources> <Style x:Key="RoundedButton" TargetType="Button"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="Button"> <Grid> <Grid.RowDefinitions> <RowDefinition Height="Auto"></RowDefinition> <RowDefinition Height="30"></RowDefinition> </Grid.RowDefinitions> <Ellipse Name="Ellipse" Grid.Row="0" StrokeThickness="1" Fill="{TemplateBinding Background}" Height="40" Width="40" Stroke="White"></Ellipse> <ContentPresenter Name="Content" Grid.Row="0" FontSize="{TemplateBinding FontSize}" FontFamily="{TemplateBinding FontFamily}" Content="{TemplateBinding Content}" HorizontalAlignment="Center" VerticalAlignment="Center"></ContentPresenter> <TextBlock Text="{TemplateBinding Tag}" Grid.Row="1" Margin="0,-2,0" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="12" Foreground="White" FontFamily="Segoe Ui"></TextBlock> <VisualStateManager.VisualStateGroups> <VisualStateGroup x:Name="CommonStates"> <VisualState x:Name="Normal"/> <VisualState x:Name="PointerOver"> <Storyboard> <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="Ellipse"> <DiscreteObjectKeyFrame KeyTime="0" Value="0.8"/> </ObjectAnimationUsingKeyFrames> </Storyboard> </VisualState> <VisualState x:Name="Pressed"> <Storyboard> <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Fill" Storyboard.TargetName="Ellipse"> <DiscreteObjectKeyFrame KeyTime="0" Value="White"/> </ObjectAnimationUsingKeyFrames> <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="Content"> <DiscreteObjectKeyFrame KeyTime="0" Value="Red"/> </ObjectAnimationUsingKeyFrames> </Storyboard> </VisualState> </VisualStateGroup> </VisualStateManager.VisualStateGroups> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style> </Page.Resources> <StackPanel Orientation="Horizontal" HorizontalAlignment="Center"> <Button Content="" Style="{StaticResource RoundedButton}" FontSize="19" FontFamily="Segoe Ui Symbol" Tag="Delete" Background="RoyalBlue" /> <Button Content="" Margin="10,0" Style="{StaticResource RoundedButton}" FontSize="16" FontFamily="Segoe Ui Symbol" Tag="Mail" Background="ForestGreen" /> <Button Content="" Margin="10,0" Style="{StaticResource RoundedButton}" FontSize="17" FontFamily="Segoe Ui Symbol" Tag="Back" Background="Red" /> </StackPanel> 产量 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- 在Windows 2008上限制传输速度
- .net – 如何通过WMI获取IIS应用程序信息
- Windows下用批处理批量创建快捷方式并改名
- windows-phone-7 – 以编程方式关闭WP7应用程序?
- 从PowerShell访问Windows凭据管理器
- xaml – CollectionViewSource“值不在预期范围内.”
- windows – 如何获取MediaCapture的预览缓冲区 – 通用应用
- windows-server-2008 – 运行多个Hypervisor
- 如何在Windows 10上安装graphviz-2.38
- .net – ProcessStartInfo的UseShellExecute和CreateNoWind
推荐文章
站长推荐
热点阅读