我正在尝试使用 WindowChrome 类自定义窗口边框。没有 Windows Aero 玻璃效果。正如预期的那样,我最终得到了一个黑人寄宿生。
但我最终也没有标题按钮
从微软我了解到我可以通过将窗口样式设置为 null 来使用标准窗口来克服这些问题http://msdn.microsoft.com/en-us/library/microsoft.windows.shell.windowchrome.aspx http://msdn.microsoft.com/en-us/library/microsoft.windows.shell.windowchrome.aspx
但我没有成功。
有人有这方面的工作示例吗?或者某种可以解释如何解决我的问题的链接?
我尝试编写一个简单的示例代码,并将 WindowStyle 更改为 none,但它不起作用。这是我的示例代码:
<Window x:Class="WpfApplication1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:shell="clr-namespace:Microsoft.Windows.Shell;assembly=Microsoft.Windows.Shell" Title="Window" Height="400" Width="500">
<Window.Style>
<Style TargetType="{x:Type Window}">
<Setter Property="shell:WindowChrome.WindowChrome">
<Setter.Value>
<shell:WindowChrome />
</Setter.Value>
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Window}">
<Grid>
<Border Background="White" Margin="{Binding Source={x:Static shell:SystemParameters2.Current}, Path=WindowNonClientFrameThickness}">
<ContentPresenter Content="{TemplateBinding Content}" />
</Border>
<TextBlock Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Title}"
VerticalAlignment="Top" HorizontalAlignment="Left"
Margin="36,8,0,0"/>
<Image Source="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Icon}"
VerticalAlignment="Top" HorizontalAlignment="Left"
Margin="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(shell:WindowChrome.WindowChrome).ResizeBorderThickness}"
Width="{Binding Source={x:Static shell:SystemParameters2.Current}, Path=SmallIconSize.Width}"
shell:WindowChrome.IsHitTestVisibleInChrome="True"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Window.Style>
<Grid/>
</Window>
我也在尝试 WindowChrome,到目前为止我的应用程序运行正常:
<Window ...>
<Window.Style>
<Style TargetType="{x:Type Window}">
<Setter Property="shell:WindowChrome.WindowChrome">
<Setter.Value>
<shell:WindowChrome CaptionHeight="15"
CornerRadius="0"
GlassFrameThickness="0,0,0,-1"
NonClientFrameEdges="None"
ResizeBorderThickness="5"
UseAeroCaptionButtons="true"/>
</Setter.Value>
</Setter>
</Style>
</Window.Style>
<!-- Add content to normal window content (not with template, at first) -->
<Grid>
</Grid>
</Window>
如果您使用上面的代码,您应该有一个空窗口,只有标题按钮和一个玻璃窗口。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)