通用模板,窗口样式

 <!-- 通用窗口模板 -->
<ControlTemplate x:Key="CustomWindowTemplate" TargetType="Window">
<Border Margin="" CornerRadius="5,5,5,5" Background="#1BA1E2" MouseLeftButtonDown="CustomWindow_MouseLeftButtonDown">
<Border.Effect>
<DropShadowEffect BlurRadius="" RenderingBias="Performance" ShadowDepth="" Opacity=""/>
</Border.Effect>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height=""></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Grid Grid.Row="">
<TextBlock HorizontalAlignment="Left" VerticalAlignment="Center" Margin="10,0,0,0"
Text="{TemplateBinding Title}" Foreground="#FFFFFF" FontSize=""></TextBlock>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,10,10,0" VerticalAlignment="Top">
<Button Height="" Width="" Content="-"
Style="{StaticResource ResourceKey=CustomWindowMenuBtn}" Click="CustomWindowBtnMinimized_Click" />
<Button Height="" Width="" Content="□"
Style="{StaticResource ResourceKey=CustomWindowMenuBtn}" Click="CustomWindowBtnMaxNormal_Click" />
<Button Height="" Width="" Content="×"
Style="{StaticResource ResourceKey=CustomWindowMenuBtn}" Click="CustomWindowBtnClose_Click" />
</StackPanel>
</Grid>
<Grid Grid.Row="">
<AdornerDecorator>
<ContentPresenter></ContentPresenter>
</AdornerDecorator>
</Grid>
</Grid>
</Border>
</ControlTemplate> <!-- 通用窗口样式 -->
<Style x:Key="CustomWindowChrome" TargetType="Window">
<Setter Property="AllowsTransparency" Value="True"></Setter>
<Setter Property="Background" Value="Transparent"></Setter>
<Setter Property="WindowStyle" Value="None"></Setter>
<Setter Property="ResizeMode" Value="NoResize"></Setter>
<Setter Property="Template" Value="{StaticResource CustomWindowTemplate}"></Setter>
</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. <Style x:Key="CustomWindowChrome" TargetType="Window">
  34. <Setter Property="AllowsTransparency" Value="True"></Setter>
  35. <Setter Property="Background" Value="Transparent"></Setter>
  36. <Setter Property="WindowStyle" Value="None"></Setter>
  37. <Setter Property="ResizeMode" Value="NoResize"></Setter>
  38. <Setter Property="Template" Value="{StaticResource CustomWindowTemplate}"></Setter>
  39. </Style>

WPF窗口模板——Style样式的更多相关文章

  1. WPF 中的style 样式

    WPF相较于以前学的WinForm,WPF在UI设计与动画方面的炫丽是最吸引我来学习的.在WPF中XMAL代码的引入使得代码的编写能够前后端分离,为获得更好的界面,也使得我们不得不分出一半的时间花在前 ...

  2. 自定义WPF 窗口样式

    原文:自定义WPF 窗口样式 Normal 0 false 7.8 pt 0 2 false false false EN-US ZH-CN X-NONE 自定义 Window 在客户端程序中,经常需 ...

  3. 《Programming WPF》翻译 第5章 5.数据模板和样式

    原文:<Programming WPF>翻译 第5章 5.数据模板和样式 让我们想象一下我们想要实现TTT更有娱乐性的一个版本(这是大部分游戏中最重要的特色).例如,TTT的一种变体允许玩 ...

  4. WPF笔记(1.9 样式和控件模板)——Hello,WPF!

    原文:WPF笔记(1.9 样式和控件模板)--Hello,WPF! 资源的另一个用途是样式设置: <Window >  <Window.Resources>    <St ...

  5. 【WPF】MVVM动态修改Bingding的另一种思路——用Style样式

    问题场景: 界面上有个ListBox控件,它的内容Item绑定了一个列表,即 ItemsSource =”{Binding StudentList}”.这个StudentList列表在该界面View对 ...

  6. WPF ScrollViewer(滚动条) 自定义样式表制作 (改良+美化)

    原文:WPF ScrollViewer(滚动条) 自定义样式表制作 (改良+美化) 注释直接写在代码里了   不太理解意思的 可以先去看看我上一篇  WPF ScrollViewer(滚动条)  自定 ...

  7. WPF 日历模板改写

    原文:WPF 日历模板改写 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/BYH371256/article/details/83346221  本 ...

  8. WPF 自定义键盘焦点样式(FocusVisualStyle)

    WPF 自带的键盘焦点样式是与传统控件样式搭配的,但 WPF 凭着其强大的自定义样式的能力,做出与传统控件样式完全不同风格的 UI 简直易如反掌.这时,其自带的键盘焦点样式(FocusVisualSt ...

  9. WPF ListBoxItem模板中添加CheckBox选中问题

    原文:WPF ListBoxItem模板中添加CheckBox选中问题 是这样的,需要一个ListBox来展示照片,并添加一个选中的CheckBox.这就需要对ListBox的ItemTemplate ...

随机推荐

  1. C#中DataTable与泛型集合互转(支持泛型集合中对象包含枚举)

    最近在做WCF,因为是内部接口,很多地方直接用的弱类型返回(DataSet),这其实是一种非常不好的方式,最近将项目做了修改,将所有接口返回值都修改成强类型,这样可以减少很多与客户端开发人员的沟通,结 ...

  2. 8、列表:ion-list

    1.基本样式 no-lines 属性 隐藏列表项之间的分割符 inset 属性 去掉 ion-list的 外边框. 默认 的 ion-list 是有外边框的.   /* ---示例代码----*/ & ...

  3. 05.File类的学习

    File  是文件的意思 File类是一个静态类,所以File类是一个工具类 File类是专门操作文件的类 File的常用方法 namespace _16.File类的学习 { class Progr ...

  4. Android - Rxjava 使用和原理

    用RxJava写的一个Android的小Demo 我所理解的RxJava——上手其实很简单 http://www.jianshu.com/p/5e93c9101dc5

  5. jqueryUI学习

    01.选项卡 拖动按钮<div id="tabs"> <ul> <li><a href="#tabs-1">第一 ...

  6. 编程语言的发展历史剧。(参考https://baijiahao.baidu.com/s?id=1588675986991787716&wfr=spider&for=pc)

    1800年 约瑟夫·玛丽·雅卡尔(Joseph Marie Jacquard),设计出人类历史 上首台可设计织布机——雅卡尔织布机,对将来发展出其他可编程机器起了重要作用 1842年 阿达·洛夫莱斯( ...

  7. python调用其他文件的类和函数

    在同一个文件夹下 调用函数 source.py文件: def func(): pass new.py文件: import source # 或者 from source import func 调用类 ...

  8. 打杂程序员之nginx服务配置

    现在公司要在服务器上多加个网站用同一个nginx服务器,而且都是公用80端口. 因为服务器上跑着好几个网站了,所以配置文件配置完成时候要检测一下能不能用,用nginx -t:最好不要直接杀死nginx ...

  9. sql server中将自增长列归零

    一个项目完成后数据库中会有很多无用的测试数据,可以使用delete * 将数据全部删除,但自增长列(一般是主键)基数不会归零,使用TRUNCATE函数可以将表中数据全部删除,并且将自增长列基数归零.一 ...

  10. qt打开url

    QDesktopServices::openUrl(QUrl(QLatin1String(“http://blog.const.net.cn“)))