我正在尝试使用WindowChrome类自定义窗口边框。没有Windows Aero玻璃效果。不出所料,我最终选择了黑人。 但是我也最终没有字幕按钮
I'm trying to customize a window border by using the WindowChrome class. Without Windows Aero glass effects. As expected I end up with a black boarder. But i also end up without caption buttons
从Microsoft我了解到我可以通过将窗口样式设置为null来使用标准窗口来克服这些问题 msdn.microsoft /en-us/library/microsoft.windows.shell.windowchrome.aspx
From Microsoft i learn that i can use the standard window by setting the window style to null to overcome these problem msdn.microsoft/en-us/library/microsoft.windows.shell.windowchrome.aspx
但是我没有成功。
有人有这个可行的例子吗?还是某种可以解释如何解决我的问题的链接?
Do anyone have a working example of this? Or a link of some sort that can explain how to solve my problem?
我试图做一个简单的示例代码,并将WindowStyle更改为none,但无法正常工作。这是我的示例代码:
I have tried to do a simple example code, and change the WindowStyle to none but it wont work. This is my example code:
<Window x:Class="WpfApplication1.Window1" xmlns="schemas.microsoft/winfx/2006/xaml/presentation" xmlns:x="schemas.microsoft/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,我的应用程序也可以正常工作到目前为止:
I'm experimenting with WindowChrome too and my application works so far:
<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>如果您使用的是我的话,应该有一个空的窗口,除了标题按钮和玻璃窗外,别无其他上面的代码。
You should have an empty window with nothing more than the caption buttons and a glass window if you use my code above.
更多推荐
如何在WPF中使用不带Windows Aero玻璃效果的WindowChrome,黑色边框
发布评论