2013-11-28 33 views
0

我很新的WPF,我需要定製一個窗口,如下所示:如何更改WPF中的窗口樣式?

http://i41.tinypic.com/2dtb0hh.jpg http://i41.tinypic.com/2dtb0hh.jpg

默認模式是這樣的:

http://i42.tinypic.com/r76lno.jpg http://i42.tinypic.com/r76lno.jpg

我想知道是什麼使用,如果在互聯網上有任何教程可以幫助我實現這一目標。我搜索了互聯網,但找不到與我想要實現的任何內容類似的內容。

+0

到目前爲止你做了什麼?你確切的問題是什麼?另外,您不能簡單地更改標準消息框的外觀。你必須創建自己的一個。 – Somedust

回答

0

關於WPF的好處是,您可以使用自定義樣式對幾乎所有東西進行樣式設置。如果你使用混合,你可以很容易地開始,通過右鍵單擊控件並選擇樣式 - >創建模板 - >創建副本。題目本身是相當大的,所以我給你一些教程,讓你開始:下面的例子

+0

非常感謝!我會研究它。 – Vlad

1

的創建要求的WPF窗口。

NOTES:

  1. 設置WindowStyle屬性爲「無」隱藏的標準OS鉻
  2. 在下面的示例中所引用的圖像不包括
  3. Click Event將需要處理對於「是」和「否」按鈕
<Window x:Class="CustomConfirmBox.ConfirmBox" 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     Title="ConfirmBox" Height="275" Width="376" 
     WindowStyle="None" > 
    <Grid> 
    <Grid.RowDefinitions> 
     <RowDefinition Height="38" /> 
     <RowDefinition Height="*" /> 
    </Grid.RowDefinitions> 
    <Border Grid.Row="0" Background="CornflowerBlue" > 
     <StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch" > 
     <Image x:Name="ConfirmIcon" Margin="6" Source="Icon.jpg" /> 
     <TextBlock Text="Confirmation" VerticalAlignment="Center" FontSize="20" Foreground="White" /> 
     </StackPanel> 
    </Border> 
    <Grid Grid.Row="1"> 
     <Grid.RowDefinitions> 
     <RowDefinition Height="*"/> 
     <RowDefinition Height="Auto"/> 
     <RowDefinition Height="63"/> 
     </Grid.RowDefinitions> 
     <Grid.ColumnDefinitions> 
     <ColumnDefinition Width="35" /> 
     <ColumnDefinition Width="*" /> 
     <ColumnDefinition Width="35" /> 
     </Grid.ColumnDefinitions> 
     <TextBlock Grid.Row="0" Grid.Column="1" TextWrapping="Wrap" HorizontalAlignment="Center" 
       LineStackingStrategy="BlockLineHeight" LineHeight="30" TextAlignment="Center" Margin="0,20" > 
     Meter data and logs are deleted from the application immediately once 
     archiving is complete, while structures are kept in the application. 
     </TextBlock> 
     <TextBlock Grid.Row="1" Grid.Column="1" TextAlignment="Center" Margin="6" > 
     Are you sure you want to continue? 
     </TextBlock> 
     <Grid Grid.Row="2" Grid.Column="1" > 
     <Grid.RowDefinitions> 
      <RowDefinition Height="*" /> 
      <RowDefinition Height="Auto" /> 
      <RowDefinition Height="*" /> 
     </Grid.RowDefinitions> 
     <Grid.ColumnDefinitions> 
      <ColumnDefinition Width="*" /> 
      <ColumnDefinition Width="Auto" /> 
      <ColumnDefinition Width="*" /> 
      <ColumnDefinition Width="*" /> 
      <ColumnDefinition Width="Auto" /> 
      <ColumnDefinition Width="*" /> 
     </Grid.ColumnDefinitions> 
     <Button Grid.Row="1" Grid.Column="1" x:Name="ButtonYes" Content="Yes" 
       Background="White" Height="25" Width="73" BorderBrush="LightGray" /> 
     <Button Grid.Row="1" Grid.Column="4" x:Name="ButtonNo" Content="No" 
       Background="White" Height="25" Width="73" BorderBrush="LightGray" /> 
     </Grid> 
    </Grid> 
    </Grid> 
</Window> 
+0

我做到了,看起來就像它。我只需要讓窗口在第一行拖動就可以了。謝謝! – Vlad