我正在尝试使用WindowChrome类自定义窗口边框,但没有Windows Aero玻璃效果。如预期,我得到了一个黑色的边框。
但我也失去了标题按钮。
我从Microsoft那里学到,可以通过将窗口样式设置为null来使用标准窗口以解决这些问题。 http://msdn.microsoft.com/en-us/library/microsoft.windows.shell.windowchrome.aspx 但我无法成功实现。
有人有这方面的有效示例吗?或者有什么链接可以解释如何解决我的问题?
我已经尝试过一个简单的示例代码,并将WindowStyle更改为none,但它不起作用。这是我的示例代码:
我从Microsoft那里学到,可以通过将窗口样式设置为null来使用标准窗口以解决这些问题。 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>
UseAeroCaptionButtons
可在 .NET 4.5 的 PresentationFramework.dll 程序集中使用,但在 .NET 4.0 中不可用。 - dss539WindowChrome
和所有其他外壳类从Microsoft.Windows.Shell
命名空间中移动到了外部dll的PresantationFramework.dll
和命名空间System.Windows.Shell
中。但这仅适用于**.NET 4.5**!新链接 - webber2k6