1

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

4

2 回答 2

1

My solution involved creating a template for the Window.

First of all, set WindowStyle = None and ResizeMode = NoResize with these both properties you'll have a borderless window like this one (Opacity set to 50%):

a borderless window

In VS Designer, right click your Window Edit Template -> Edit a copy.... Now, this is the difficult part. Check for the code below:

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

I got rid of the Border and AdornerDecorator, but it's not necessary.
Wrap your ContentPresenter inside a Grid with 3 rows and 3 columns at position 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>

For the other locations, just insert Rectangles as your borders.
Unfortunately, I don't have the Code behind with me right now, but if you search for "WPF Resize window", you'll find easily.

I know it is a "hack", but it works :)

EDIT: Here's a link with the Code Behind

于 2013-10-03T04:09:00.387 回答
0

最简单的方法是为窗口渲染自己的 chrome。甚至还有Microsoft.Windows.Shell 库,它可以为您完成大部分繁重的工作。

如果您想避免所有工作,请查看WinChrome.Codeplex.com,了解我整理的一些样式。

VS2012之类的

此外,如果您想了解更多细节,我已经在Recreating Office2013/VS2012 window glow中介绍了它背后的一些解释。

于 2013-10-02T22:30:08.730 回答