zoukankan      html  css  js  c++  java
  • WPF窗口模板——Style样式

    通用模板,窗口样式

     1 <!-- 通用窗口模板 -->  
     2     <ControlTemplate x:Key="CustomWindowTemplate" TargetType="Window">  
     3         <Border Margin="3" CornerRadius="5,5,5,5" Background="#1BA1E2" MouseLeftButtonDown="CustomWindow_MouseLeftButtonDown">  
     4             <Border.Effect>  
     5                 <DropShadowEffect BlurRadius="3" RenderingBias="Performance" ShadowDepth="0" Opacity="1"/>  
     6             </Border.Effect>  
     7             <Grid>  
     8                 <Grid.RowDefinitions>  
     9                     <RowDefinition Height="50"></RowDefinition>  
    10                     <RowDefinition></RowDefinition>  
    11                 </Grid.RowDefinitions>  
    12                 <Grid Grid.Row="0">  
    13                     <TextBlock HorizontalAlignment="Left" VerticalAlignment="Center" Margin="10,0,0,0"  
    14                                    Text="{TemplateBinding Title}" Foreground="#FFFFFF" FontSize="20"></TextBlock>  
    15                     <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,10,10,0" VerticalAlignment="Top">  
    16                         <Button Height="20" Width="20" Content="-"  
    17                                 Style="{StaticResource ResourceKey=CustomWindowMenuBtn}" Click="CustomWindowBtnMinimized_Click" />  
    18                         <Button Height="20" Width="20" Content=""  
    19                                 Style="{StaticResource ResourceKey=CustomWindowMenuBtn}" Click="CustomWindowBtnMaxNormal_Click" />  
    20                         <Button Height="20" Width="20" Content="×"  
    21                                 Style="{StaticResource ResourceKey=CustomWindowMenuBtn}" Click="CustomWindowBtnClose_Click" />  
    22                     </StackPanel>  
    23                 </Grid>  
    24                 <Grid Grid.Row="1">  
    25                     <AdornerDecorator>  
    26                         <ContentPresenter></ContentPresenter>  
    27                     </AdornerDecorator>  
    28                 </Grid>  
    29             </Grid>  
    30         </Border>  
    31     </ControlTemplate>  
    32   
    33     <!-- 通用窗口样式 -->  
    34     <Style x:Key="CustomWindowChrome" TargetType="Window">  
    35         <Setter Property="AllowsTransparency" Value="True"></Setter>  
    36         <Setter Property="Background" Value="Transparent"></Setter>  
    37         <Setter Property="WindowStyle" Value="None"></Setter>  
    38         <Setter Property="ResizeMode" Value="NoResize"></Setter>  
    39         <Setter Property="Template" Value="{StaticResource CustomWindowTemplate}"></Setter>  
    40     </Style>  
    1. <!-- 通用窗口模板 -->  
    2.     <ControlTemplate x:Key="CustomWindowTemplate" TargetType="Window">  
    3.         <Border Margin="3" CornerRadius="5,5,5,5" Background="#1BA1E2" MouseLeftButtonDown="CustomWindow_MouseLeftButtonDown">  
    4.             <Border.Effect>  
    5.                 <DropShadowEffect BlurRadius="3" RenderingBias="Performance" ShadowDepth="0" Opacity="1"/>  
    6.             </Border.Effect>  
    7.             <Grid>  
    8.                 <Grid.RowDefinitions>  
    9.                     <RowDefinition Height="50"></RowDefinition>  
    10.                     <RowDefinition></RowDefinition>  
    11.                 </Grid.RowDefinitions>  
    12.                 <Grid Grid.Row="0">  
    13.                     <TextBlock HorizontalAlignment="Left" VerticalAlignment="Center" Margin="10,0,0,0"  
    14.                                    Text="{TemplateBinding Title}" Foreground="#FFFFFF" FontSize="20"></TextBlock>  
    15.                     <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,10,10,0" VerticalAlignment="Top">  
    16.                         <Button Height="20" Width="20" Content="-"  
    17.                                 Style="{StaticResource ResourceKey=CustomWindowMenuBtn}" Click="CustomWindowBtnMinimized_Click" />  
    18.                         <Button Height="20" Width="20" Content="□"  
    19.                                 Style="{StaticResource ResourceKey=CustomWindowMenuBtn}" Click="CustomWindowBtnMaxNormal_Click" />  
    20.                         <Button Height="20" Width="20" Content="×"  
    21.                                 Style="{StaticResource ResourceKey=CustomWindowMenuBtn}" Click="CustomWindowBtnClose_Click" />  
    22.                     </StackPanel>  
    23.                 </Grid>  
    24.                 <Grid Grid.Row="1">  
    25.                     <AdornerDecorator>  
    26.                         <ContentPresenter></ContentPresenter>  
    27.                     </AdornerDecorator>  
    28.                 </Grid>  
    29.             </Grid>  
    30.         </Border>  
    31.     </ControlTemplate>  
    32.   
    33.     <!-- 通用窗口样式 -->  
    34.     <Style x:Key="CustomWindowChrome" TargetType="Window">  
    35.         <Setter Property="AllowsTransparency" Value="True"></Setter>  
    36.         <Setter Property="Background" Value="Transparent"></Setter>  
    37.         <Setter Property="WindowStyle" Value="None"></Setter>  
    38.         <Setter Property="ResizeMode" Value="NoResize"></Setter>  
    39.         <Setter Property="Template" Value="{StaticResource CustomWindowTemplate}"></Setter>  
    40.     </Style>  
  • 相关阅读:
    POJ 2240 Arbitrage spfa 判正环
    POJ 3259 Wormholes spfa 判负环
    POJ1680 Currency Exchange SPFA判正环
    HDU5649 DZY Loves Sorting 线段树
    HDU 5648 DZY Loves Math 暴力打表
    HDU5647 DZY Loves Connecting 树形DP
    CDOJ 1071 秋实大哥下棋 线段树
    HDU5046 Airport dancing links 重复覆盖+二分
    HDU 3335 Divisibility dancing links 重复覆盖
    FZU1686 神龙的难题 dancing links 重复覆盖
  • 原文地址:https://www.cnblogs.com/cxdanger/p/8715340.html
Copyright © 2011-2022 走看看