禁用wpf应用程序上的aero视觉样式

时间:2013-10-02 19:32:23

标签: c# wpf aero

如何在Windows 7 / Vista中的wpf应用程序上禁用aero视觉样式。优选的方法是优先顺序。 1)申请清单 2)PINVOKE电话

2 个答案:

答案 0 :(得分:1)

我的解决方案涉及为Window创建模板。

首先,使用这两个属性设置WindowStyle = NoneResizeMode = NoResize,您将拥有像这样的无边框窗口(不透明度设置为50%):

a borderless window

在VS Designer中,右键单击窗口Edit Template -> Edit a copy...。现在,这是困难的部分。检查以下代码:

<ControlTemplate TargetType="{x:Type Window}">
    <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
         <AdornerDecorator>
             <ContentPresenter/>
         </AdornerDecorator>
       </Border>
  </ControlTemplate>

我摆脱了BorderAdornerDecorator,但没有必要 将您的ContentPresenter包裹在Grid内,在位置1,1:

处包含3行3列
<Grid>
   <Grid.RowDefinitions>
       <RowDefinition/>
       <RowDefinition/>
       <RowDefinition/>
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
       <ColumnDefinition/>
       <ColumnDefinition/>
       <ColumnDefinition/>
    </Grid.ColumnDefinitions>
    <ContentPresenter Grid.Row="1" Grid.Column="1"/>
</Grid>

对于其他位置,只需插入Rectangles作为边框 不幸的是,我现在没有代码,但是如果你搜索“WPF Resize window”,你会很容易找到。

我知道这是一个“黑客”,但它有效:)

编辑:Here's a link with the Code Behind

答案 1 :(得分:0)

最简单的方法是为窗口渲染自己的镶边。甚至还有Microsoft.Windows.Shell library将为你完成大部分艰苦工作。

如果你想避免所有的工作,那么看一下我WinChrome.Codeplex.com的一些风格吧。

VS2012 like

此外,如果你想要更多细节,我在Recreating Office2013/VS2012 window glow中已经介绍了相当多的解释。

相关问题