2013-10-02 43 views
1

如何在Windows 7/Vista中禁用wpf应用程序的航空视觉样式。优选的方法是按照优先顺序。 1)应用程序清单 2)PINVOKE调用在wpf应用程序中禁用航空视觉样式

+1

[?你尝试过什么(http://mattgemmell.com/2008/12/08/你试过什么/) –

+0

我碰到过SetThemeAppProperties。 msdn.microsoft.com/en-us/library/windows/desktop/bb759825(v=vs.85).aspx – TrustyCoder

回答

1

我的解决方案涉及到为窗口创建模板。

首先,设置WindowStyle = NoneResizeMode = NoResize与这些两个属性你有这样一个(不透明度设置为50%),无边框窗口:

a borderless window

在VS设计器中,右键单击您窗口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的,但它是没有必要的。
包装你ContentPresenterGrid 3行3列在1,1位置:

<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