通用模板,窗口样式

 <!-- 通用窗口模板 -->
<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. 深入理解JavaScript系列(36):设计模式之中介者模式

    介绍 中介者模式(Mediator),用一个中介对象来封装一系列的对象交互.中介者使各对象不需要显式地相互引用,从而使其耦合松散,而且可以独立地改变它们之间的交互. 主要内容来自:http://www ...

  2. js中判断对象是否存在

    s中判断对象是否存在,写法有很多种: 第一种:if (!myObj) { var myObj = { }; }第二种:var global = this;  if (!global.myObj) {  ...

  3. C#简单实现读取txt文本文件并分页存储到数组

    最近做一个VR项目,需要把某个中草药的介绍信息分页显示到unity场景里然后用VR手柄切换信息. unity的脚本是c#,就先在本地写了个代码测试了一下,利用控制台测试输出,到时候拷贝函数过去再结合交 ...

  4. 前端使用express+node实现接口模拟及websocket通讯

    简述如何使用node+express实现接口连接及入门websocket通讯.使用技术栈:node + express + typescript + websocket. 1.接口实现 这里描述前端如 ...

  5. 设备信息工具pv-jd快速上手

    pv-jd 这是一个判断设备信息的小工具,可以判断出移动端还是PC端,提供了多种API 快速开始 安装npm install pv-jd -S 示例 import {judgeDevice, judg ...

  6. The only person standing in your way is you.

    The only person standing in your way is you.唯一阻碍你的人是你自己.

  7. 我为什么不用Django而用Flask?

    前言 对于初学者来说,找到一个好的框架来学习或者项目开发都是非常有必要的,而当你有一定开发经验后,你应该选择适合当前业务需要的框架.我这里并不想探讨哪个框架好哪个不好,这个永恒的话题就跟探讨“世界上哪 ...

  8. greenplum维护

    1.用户管理 psql -d sea CREATE DATABASE BI; CREATE USER ubi WITH PASSWORD 'pwdbi' NOSUPERUSER; GRANT ALL ...

  9. swftools 将pdf转换swf常见问题说明

    swftools将PDF转成swfSWFTools提供了一系列将各种文件转成swf的工具: font2swf.exe gif2swf.exe jpeg2swf.exe pdf2swf.exe png2 ...

  10. HTTP Strict Transport Security

    HTTP Strict Transport Security (通常简称为HSTS) 是一个安全功能,它告诉浏览器只能通过HTTPS访问当前资源, 禁止HTTP方式. 作用 一个网站接受一个HTTP的 ...