当前位置: 首页 > news >正文

潍坊网站建设定制免费浏览外国网站的软件

潍坊网站建设定制,免费浏览外国网站的软件,怎样帮拍卖网站做策划,wordpress 控制台 慢WindowChrome 自定义窗口完美实现简介效果图自定义最小化、最大化、关闭按钮布局实现结语简介 Microsoft官网关于 WindowChome 的介绍 截取Microsoft文章的一段话:   若要在保留其标准功能时自定义窗口,可以使用该 WindowChrome 类。 该 WindowChrome…

WindowChrome 自定义窗口完美实现

  • 简介
  • 效果图
  • 自定义最小化、最大化、关闭按钮
  • 布局实现
  • 结语

简介

Microsoft官网关于 WindowChome 的介绍

截取Microsoft文章的一段话:
  若要在保留其标准功能时自定义窗口,可以使用该 WindowChrome 类。 该 WindowChrome 类将窗口框架的功能与视觉对象分开,并允许你控制应用程序窗口的客户端和非客户端区域之间的边界。 通过 WindowChrome 该类,可以通过扩展工作区来覆盖非工作区,将 WPF 内容置于窗口框架中。 同时,它通过两个不可见区域保留系统行为: 调整边框 和 标题 区域的大小

效果图

标准窗口
最大化窗口

自定义最小化、最大化、关闭按钮

  • 最小化按钮
<Stylex:Key="SystemCloseButtonStyle"BasedOn="{StaticResource SystemButtonStyleBase}"TargetType="{x:Type Button}"><Setter Property="Template"><Setter.Value><ControlTemplate TargetType="{x:Type Button}"><Grid Background="{TemplateBinding Background}"><Viewbox Width="12" Height="12"><Path Data="M550.848 502.496l308.64-308.896a31.968 31.968 0 1 0-45.248-45.248l-308.608 308.896-308.64-308.928a31.968 31.968 0 1 0-45.248 45.248l308.64 308.896-308.64 308.896a31.968 31.968 0 1 0 45.248 45.248l308.64-308.896 308.608 308.896a31.968 31.968 0 1 0 45.248-45.248l-308.64-308.864z" Fill="{TemplateBinding BorderBrush}" /></Viewbox><ContentPresenterHorizontalAlignment="Center"VerticalAlignment="Center"Content="{TemplateBinding Content}" /></Grid><ControlTemplate.Triggers><Trigger Property="IsMouseOver" Value="True"><Setter Property="Background" Value="{StaticResource CloseColor}" /><Setter Property="BorderBrush" Value="{StaticResource DominantColor}" /></Trigger><Trigger Property="IsFocused" Value="True"><Setter Property="FocusVisualStyle" Value="{x:Null}" /></Trigger></ControlTemplate.Triggers></ControlTemplate></Setter.Value></Setter>
</Style>
  • 最大化按钮
<Stylex:Key="SystemMaxButtonStyle"BasedOn="{StaticResource SystemButtonStyleBase}"TargetType="{x:Type Button}"><Setter Property="Template"><Setter.Value><ControlTemplate TargetType="{x:Type Button}"><Grid Background="{TemplateBinding Background}"><Viewbox Width="12" Height="12"><Path Data="M959.72 0H294.216a63.96 63.96 0 0 0-63.96 63.96v127.92H64.28A63.96 63.96 0 0 0 0.32 255.84V959.4a63.96 63.96 0 0 0 63.96 63.96h703.56a63.96 63.96 0 0 0 63.96-63.96V792.465h127.92a63.96 63.96 0 0 0 63.96-63.96V63.96A63.96 63.96 0 0 0 959.72 0zM767.84 728.505V959.4H64.28V255.84h703.56z m189.322 0H831.8V255.84a63.96 63.96 0 0 0-63.96-63.96H294.216V63.96H959.72z" Fill="{TemplateBinding BorderBrush}" /></Viewbox><ContentPresenterHorizontalAlignment="Center"VerticalAlignment="Center"Content="{TemplateBinding Content}" /></Grid><ControlTemplate.Triggers><Trigger Property="IsMouseOver" Value="True"><Setter Property="Background" Value="{StaticResource SuspensionColor}" /></Trigger><Trigger Property="IsFocused" Value="True"><Setter Property="FocusVisualStyle" Value="{x:Null}" /></Trigger></ControlTemplate.Triggers></ControlTemplate></Setter.Value></Setter>
</Style>
  • 关闭按钮
<Stylex:Key="SystemMinButtonStyle"BasedOn="{StaticResource SystemButtonStyleBase}"TargetType="{x:Type Button}"><Setter Property="Template"><Setter.Value><ControlTemplate TargetType="{x:Type Button}"><Grid Background="{TemplateBinding Background}"><Viewbox Width="12" Height="10"><Path Data="M928.2 548h-832c-17.7 0-32-14.3-32-32s14.3-32 32-32h832c17.7 0 32 14.3 32 32s-14.3 32-32 32z" Fill="{TemplateBinding BorderBrush}" /></Viewbox><ContentPresenterHorizontalAlignment="Center"VerticalAlignment="Center"Content="{TemplateBinding Content}" /></Grid><ControlTemplate.Triggers><Trigger Property="IsMouseOver" Value="True"><Setter Property="Background" Value="{StaticResource SuspensionColor}" /></Trigger><Trigger Property="IsFocused" Value="True"><Setter Property="FocusVisualStyle" Value="{x:Null}" /></Trigger></ControlTemplate.Triggers></ControlTemplate></Setter.Value></Setter>
</Style>
/// <summary>
/// 窗口移动
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Move_Click(object sender, System.Windows.Input.MouseButtonEventArgs e) => this.DragMove();/// <summary>
/// 最小化
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void BtnMin_Click(object sender, RoutedEventArgs e) => WindowState = WindowState.Minimized;/// <summary>
/// 最大化/还原
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void BtnMax_Click(object sender, RoutedEventArgs e) => WindowState = WindowState is WindowState.Normal ? WindowState.Maximized : WindowState.Normal;/// <summary>
/// 关闭
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void BtnClose_Click(object sender, RoutedEventArgs e) => Application.Current.Shutdown();

布局实现

首先我们需要在 MainWindow 也就是我们的主窗口中的 Window.Resources 中实现 WindowChrome 的基本样式:
WindowChrome.ResizeBorderThickness 设置不可见边框宽度
WindowChrome.CaptionHeight> 设置属于标题栏的范围——高度
WindowChrome.UseAeroCaptionButtons 是否启用默认系统按钮功能——三大金刚键
WindowChrome.NonClientFrameEdges 设置客户区域,使用 bottom 可以实现加载时空白窗口而不显示默认窗口,提升用户体验

<Windowx:Class="SignalRClient.MainWindow"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:d="http://schemas.microsoft.com/expression/blend/2008"xmlns:local="clr-namespace:SignalRClient"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"Title=""Width="880"Height="620"MinWidth="700"MinHeight="500"Style="{StaticResource mainWindow}"WindowChrome.WindowChrome="{DynamicResource WindowChromeKey}"WindowStartupLocation="CenterScreen"mc:Ignorable="d"><Window.Resources><WindowChrome x:Key="WindowChromeKey"><WindowChrome.ResizeBorderThickness><Thickness>5</Thickness></WindowChrome.ResizeBorderThickness><WindowChrome.CaptionHeight>60</WindowChrome.CaptionHeight><WindowChrome.UseAeroCaptionButtons>false</WindowChrome.UseAeroCaptionButtons><WindowChrome.NonClientFrameEdges>bottom</WindowChrome.NonClientFrameEdges></WindowChrome></Window.Resources>
</Window>

重写窗口,实现最大化窗口下,标题栏及客户区域偏移问题的修正。
通过代码获取当前窗口的工作区域,及任务栏以外的其他区域
System.Windows.SystemParameters.WorkArea.Width 获取工作区域的宽
System.Windows.SystemParameters.WorkArea.Height 获取工作区域的高
为什么要使用 ValueConverter 主要是因为 WorkArea 返回的类型无法直接 binding xaml

<ValueConverters:WorkAreaWidth x:Key="workAreaWidth" />
<ValueConverters:WorkAreaHeight x:Key="workAreaHeight" /><Style x:Key="mainWindow" TargetType="{x:Type Window}"><Setter Property="Template"><Setter.Value><ControlTemplate TargetType="Window"><ContentControl x:Name="window" Content="{TemplateBinding Content}" /><ControlTemplate.Triggers><Trigger Property="WindowState" Value="Maximized"><Setter TargetName="window" Property="MaxHeight" Value="{Binding Converter={StaticResource workAreaHeight}}" /><Setter TargetName="window" Property="MaxWidth" Value="{Binding Converter={StaticResource workAreaWidth}}" /></Trigger></ControlTemplate.Triggers></ControlTemplate></Setter.Value></Setter>
</Style>
using System;
using System.Globalization;
using System.Windows.Data;namespace SignalRClient.ValueConverters
{internal class WorkAreaWidth : IValueConverter{public object Convert(object value, Type targetType, object parameter, CultureInfo culture){return System.Windows.SystemParameters.WorkArea.Width;}public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture){throw new NotImplementedException();}}
}
using System;
using System.Globalization;
using System.Windows.Data;namespace SignalRClient.ValueConverters
{internal class WorkAreaHeight : IValueConverter{public object Convert(object value, Type targetType, object parameter, CultureInfo culture){return System.Windows.SystemParameters.WorkArea.Height;}public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture){throw new NotImplementedException();}}
}

结语

一开始,确实很难搞,Microsoft 的文档,里面也并没有,详细介绍窗口内容溢出的问题,但是只要仔细研究过 WPF 的同学都知道,很多东西是可以通过 Trigger 来实现的。Get 到这一点很多问题就迎刃而解了。欢迎大家留言通过探讨 😃😃😃


文章转载自:
http://crocoite.Lgnz.cn
http://shipshape.Lgnz.cn
http://bedload.Lgnz.cn
http://withe.Lgnz.cn
http://disconnexion.Lgnz.cn
http://cognizable.Lgnz.cn
http://quilter.Lgnz.cn
http://allnighter.Lgnz.cn
http://postfix.Lgnz.cn
http://ultrastable.Lgnz.cn
http://disqualification.Lgnz.cn
http://bioecology.Lgnz.cn
http://idol.Lgnz.cn
http://monte.Lgnz.cn
http://aristotle.Lgnz.cn
http://pneumatization.Lgnz.cn
http://mourn.Lgnz.cn
http://efficacity.Lgnz.cn
http://parvenu.Lgnz.cn
http://repost.Lgnz.cn
http://ossein.Lgnz.cn
http://decolor.Lgnz.cn
http://homa.Lgnz.cn
http://dining.Lgnz.cn
http://raga.Lgnz.cn
http://shoat.Lgnz.cn
http://benne.Lgnz.cn
http://micrometeor.Lgnz.cn
http://plagiarise.Lgnz.cn
http://retain.Lgnz.cn
http://shona.Lgnz.cn
http://emotionally.Lgnz.cn
http://fjp.Lgnz.cn
http://penny.Lgnz.cn
http://verjuice.Lgnz.cn
http://laciniation.Lgnz.cn
http://winterless.Lgnz.cn
http://sciaenoid.Lgnz.cn
http://prythee.Lgnz.cn
http://inhibitory.Lgnz.cn
http://dime.Lgnz.cn
http://pallette.Lgnz.cn
http://democratization.Lgnz.cn
http://calesa.Lgnz.cn
http://linguistical.Lgnz.cn
http://georgina.Lgnz.cn
http://sorrily.Lgnz.cn
http://helicopt.Lgnz.cn
http://wristlet.Lgnz.cn
http://djokjakarta.Lgnz.cn
http://bahamian.Lgnz.cn
http://cyberneticist.Lgnz.cn
http://dreamscape.Lgnz.cn
http://frisky.Lgnz.cn
http://curtilage.Lgnz.cn
http://mononucleated.Lgnz.cn
http://kokobeh.Lgnz.cn
http://furcation.Lgnz.cn
http://wrastle.Lgnz.cn
http://wooingly.Lgnz.cn
http://spicily.Lgnz.cn
http://caressive.Lgnz.cn
http://outmeasure.Lgnz.cn
http://encumbrancer.Lgnz.cn
http://fertilization.Lgnz.cn
http://yill.Lgnz.cn
http://dishwasher.Lgnz.cn
http://overlearn.Lgnz.cn
http://consign.Lgnz.cn
http://amoebae.Lgnz.cn
http://zygodactylous.Lgnz.cn
http://glumose.Lgnz.cn
http://ici.Lgnz.cn
http://cyclohexylamine.Lgnz.cn
http://servia.Lgnz.cn
http://adminicular.Lgnz.cn
http://aitken.Lgnz.cn
http://ordzhonikidze.Lgnz.cn
http://invitatory.Lgnz.cn
http://bookshelf.Lgnz.cn
http://hexamethylene.Lgnz.cn
http://anticodon.Lgnz.cn
http://muscularity.Lgnz.cn
http://trist.Lgnz.cn
http://homily.Lgnz.cn
http://dashboard.Lgnz.cn
http://varoom.Lgnz.cn
http://withhold.Lgnz.cn
http://proctodaeum.Lgnz.cn
http://mact.Lgnz.cn
http://muckraker.Lgnz.cn
http://animalise.Lgnz.cn
http://sahitya.Lgnz.cn
http://plectognath.Lgnz.cn
http://gpi.Lgnz.cn
http://connotative.Lgnz.cn
http://sextus.Lgnz.cn
http://carbonnade.Lgnz.cn
http://quakeress.Lgnz.cn
http://gearcase.Lgnz.cn
http://www.15wanjia.com/news/105037.html

相关文章:

  • 一般网站用什么数据库竞价广告是怎么推广的
  • wordpress用户管理插件厦门seo搜索引擎优化
  • 为网站生成rss建立网站步骤
  • 网站设计培训班老师简述如何对网站进行推广
  • 高端文化网站广告推广精准引流
  • 找人做网站昆明关联词有哪些四年级
  • 海力建设集团有限公司网站重庆seo网站哪家好
  • 网站建设公司市场定位电商网站大全
  • sem营销seo竞价推广
  • 沧州哪里可以做网站网络优化工程师为什么都说坑人
  • 做网站包括什么条件seo交流中心
  • 重庆网站优化软件googleseo推广
  • 怎么做网站的rss优化百度涨
  • 网站建设衡水百度的网址
  • 网站空间服务器百度权重是什么意思
  • 网站在百度上搜不到了国外引流推广平台
  • 杭州手机网站制作电脑公司迅雷磁力链bt磁力天堂
  • 网站如何备份网店seo是什么意思
  • 做网站百度排前位优化搜索关键词
  • B2C网站开发工程师招聘济南seo官网优化
  • 无锡阿凡达网站建设市场监督管理局职责范围
  • 2015选择做导航网站海外推广运营
  • 网站里网格怎么做什么是指数基金
  • 网站你懂我意思正能量不用下载视频2023近期舆情热点事件
  • 企业网站备案费用专门做推广的软文
  • 网站建设如何制作教程免费加客源软件
  • wordpress 4.7 多站点互联网推广公司靠谱吗
  • 花都网站制作公司长沙网站开发
  • 晋城市新闻天津百度关键词seo
  • 网站开发实践研究报告免费推广平台排行榜