WPF如何更换标题栏的背景

WPF如何更换标题栏的背景

时间:2012-02-07 19:41 来源:Microsoft 作者:佚名 点击: 163次
问题:WPF如何更换标题栏的背景? 解决办法:免费的开源主题到没有,免费的例子我倒有。 我一起按写过一些自定义Windows Chrome的例子,你可以参考一下: (里面用到的Shell是这里的: WPF Shell Integration Library: http://code.msdn.microsoft.com/WPFShell ) Window x:Class = WpfApplication1.Window1 xmlns = http://
  

问题:WPF如何更换标题栏的背景?

解决办法:免费的开源主题到没有,免费的例子我倒有。 我一起按写过一些自定义Windows Chrome的例子,你可以参考一下:

(里面用到的Shell是这里的: WPF Shell Integration Library: http://code.msdn.microsoft.com/WPFShell )

<Window x:Class="WpfApplication1.Window1"

  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

  xmlns:shell="clr-namespace:Microsoft.Windows.Shell;assembly=Microsoft.Windows.Shell"

  Title="Window1" Height="300" Width="300"

  AllowsTransparency="True" WindowStyle="None">

 <shell:WindowChrome.WindowChrome>

  <shell:WindowChrome ResizeBorderThickness="10" 

      CaptionHeight="40"

      CornerRadius="10"

      GlassFrameThickness="0"/>

 </shell:WindowChrome.WindowChrome>

 <Grid>

  <Border Background="Gray"/>

  <Border Height="40" Background="Orange" VerticalAlignment="Top">

   <TextBlock Text="Caption" VerticalAlignment="Bottom"/>

  </Border>

 </Grid>

</Window>

因为WPF的左面应用程序的窗体外边框包括标题栏是属于系统控制的,不是WPF能修改的,所以我们的解决方法就是将系统的边框隐藏不显示,设计使用自己的边框。

你可能感兴趣的:(WPF)