2013-04-09 62 views
1

i have to make window appearance like below image 如何自定義窗口標題擴充,梯度

Window x:Class="WPF_UI.MainWindow" 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     Title="Mian Window" WindowStyle="None" AllowsTransparency="True" Width="775" Height="500" 

我有我的自定義窗口標題擴充,Gradient.How應該在WPF做。

我必須讓窗口的外觀像ABV圖像

+0

類似於http://stackoverflow.com/questions/6792275/how-to-create-custom-window-chrome-in-wpf。 – Vladimir 2013-04-09 10:16:17

回答

1

嘗試窗口tilte欄上覆蓋的StackPanel。 使WindowStyle =「None」ResizeMode =「NoResize」AND 調整控件的邊界(使STACKPANEL的頂級負數)覆蓋標題欄上的窗口堆棧面板。

<Window x:Class="WPF_UI.MainWindow" 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     WindowStyle="None" WindowStartupLocation="CenterScreen" ResizeMode="NoResize" Width="920" Height="600" > 

<Grid>....other stack panels.... 
**Here i have take stack panel to overwrite on window title bar.** 
<StackPanel Margin="0,-566,0,5" Grid.ColumnSpan="3" Height="25" DataContext="{Binding}"> 
       <StackPanel.Background> 
        <LinearGradientBrush> 
         <GradientStop Color="White" Offset=".2" /> 
         <GradientStop Color="Gray" Offset=".5" /> 
         <GradientStop Color="Black" Offset="1" /> 
        </LinearGradientBrush> 
       </StackPanel.Background> 
       <TextBlock HorizontalAlignment="Left" VerticalAlignment="Center" Margin="1,5,0,0"> APPLICATION NAME 
       </TextBlock> 
       <Button Content="Close" Margin="860,-17,0,0" VerticalAlignment="Center" HorizontalAlignment="Left" Name="btnClose" Width="40" > 
        <Button.Background> 
         <LinearGradientBrush StartPoint="0,0" EndPoint="0,2"> 
          <GradientStop Color="Black" Offset=".2" /> 
          <GradientStop Color="Gray" Offset=".5" /> 
          <GradientStop Color="White" Offset="1" /> 
         </LinearGradientBrush> 
        </Button.Background> 
       </Button> 
      </StackPanel> 
</Grid>