Cin*_*ird 10 c# wpf .net-4.0 window-chrome aero-glass
我正在尝试使用WindowChrome类来自定义窗口边框.没有Windows Aero玻璃效果.正如所料,我最终得到了一个黑色的寄宿生.但我最终也没有标题按钮
从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>
Run Code Online (Sandbox Code Playgroud)
我也在尝试使用 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>
Run Code Online (Sandbox Code Playgroud)
如果你使用我上面的代码,你应该有一个空窗口,只有标题按钮和一个玻璃窗口。