将窗口按钮带到前面

时间:2012-03-17 02:16:10

标签: c# wpf windows xaml

我目前正在为Windows开发一个Twitter应用程序,类似于OSX的Twitter客户端。

我正在使用找到here的Windows Shell Extensions库来创建整个窗口Aero,并且能够扩展到指定窗口位置的范围之外。

我希望窗口按钮(最小化,最大化,关闭)显示在具有白色背景的网格顶部。这是我认为可以内置到Windows中的功能,但显然我错了。

以下两张图片说明了我的观点。在第二张图片中,我希望窗口按钮优先于白色背景网格,而不是像显示的那样。

是否有某种代码段或XAML-snippet可以帮助我?有没有其他人曾经遇到过这个问题?

Window sized so that buttons show Window sized so that buttons don't show.

2 个答案:

答案 0 :(得分:2)

我偶然发现了一个简单而又肮脏的解决方案。我刚刚绕过Windows按钮的外部,并将外部背景设置为白色,或者我使用的任何背景颜色。然后我就把矩形拼凑起来让它看起来很漂亮。

以下是生成的代码:

<Grid HorizontalAlignment="Stretch" VerticalAlignment="Top" Grid.Row="0" Height="20">
    <Grid.ColumnDefinitions>
      <ColumnDefinition Width="1.0*" />
      <ColumnDefinition Width="105" />
      <ColumnDefinition Width="5" />
    </Grid.ColumnDefinitions>
    <Rectangle Grid.Column="0" Fill="#FFFFFFFF" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
    <Path HorizontalAlignment="Stretch" Grid.Column="1" Stretch="Fill" VerticalAlignment="Bottom" Height="20" Fill="#FFFFFFFF" Data="M 0,4.11334L 4.008,4.11334C 1.792,4.11334 0,2.27332 0,0L 0,4.11334 Z M 140,4.11334L 135.957,4.11334C 138.192,4.11334 140,4.11334 140,0L 140,4.11334 Z  " />
    <Border Grid.Column="2" CornerRadius="0, 10, 0, 0" Background="#FFFFFFFF" BorderThickness="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
  </Grid>

这是最终的图像:

enter image description here

答案 1 :(得分:0)

你应该隐藏你的最小化最大化和关闭按钮,并绘制你自己的如此描述。

http://winsharp93.wordpress.com/2009/07/21/wpf-hide-the-window-buttons-minimize-restore-and-close-and-the-icon-of-a-window/