大佬教程收集整理的这篇文章主要介绍了使用WindowChrome在WPF窗口上显示默认窗口按钮,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
但是,我仍然喜欢非样式窗口上显示的默认最小化/最大化/关闭按钮.
有没有什么办法可以使用WindowChrome设置窗口样式但仍保留默认按钮?
<Style x:Key="MainWindow" TargetType="{x:Type Window}"> <Setter Property="WindowChrome.WindowChrome"> <Setter.Value> <WindowChrome CaptionHeight="30" ResizeBorderThickness="5" /> </Setter.Value> </Setter> </Style> <Window Style="{Staticresource MainWindow}"> <Grid BACkground="Black"> <MyContent /> </Grid> </Window>
这会产生一个很大的黑色窗口(太棒了!),但没有任何最小/最大/关闭按钮,因为它们隐藏在网格后面(不太好).按钮仍然是可点击的,所以它们显然在那里.
不,我不这么认为.您可以将GlassFrameThickness属性设置为0以禁用按钮,然后您将不得不创建自己的自定义按钮.您可以参考以下项目中的一些示例:https://wpfwindow.codeplex.com/.
如果你想要Window 10风格的标题按钮,你可以使用Segoe MDL2 Assets字体系列:
<Style x:Key="CaptionButtonStyle" TargetType="Button"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="Button"> <Grid x:Name="LayoutRoot" BACkground="Transparent" Width="44" Height="30"> <TextBlock x:Name="txt" Text="{TemplateBinding Content}" FontFamily="Segoe MDL2 Assets" FontSize="10" Foreground="#999999" HorizontalAlignment="Center" VerticalAlignment="Center" RenderOptions.ClearTypeHint="Auto" TextOptions.TextRenderingMode="Aliased" TextOptions.TextFormatTingMode="Display"/> </Grid> <ControlTemplate.triggers> <trigger Property="IsMouSEOver" Value="True"> <Setter TargetName="LayoutRoot" Property="BACkground" Value="#E5E5E5"/> <Setter TargetName="txt" Property="Foreground" Value="#000000"/> </trigger> </ControlTemplate.triggers> </ControlTemplate> </Setter.Value> </Setter> </Style> <Style x:Key="MinimizeButtonStyle" TargetType="Button" BasedOn="{Staticresource CaptionButtonStylE}"> <Setter Property="Content" Value=""/> </Style> <Style x:Key="MaximizeButtonStyle" TargetType="Button" BasedOn="{Staticresource CaptionButtonStylE}"> <Setter Property="Content" Value=""/> </Style> <Style x:Key="RestoreButtonStyle" TargetType="Button" BasedOn="{Staticresource CaptionButtonStylE}"> <Setter Property="Content" Value=""/> </Style>
以上是大佬教程为你收集整理的使用WindowChrome在WPF窗口上显示默认窗口按钮全部内容,希望文章能够帮你解决使用WindowChrome在WPF窗口上显示默认窗口按钮所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。