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

佛山大良网站建设招聘网站建设培训心得

佛山大良网站建设招聘,网站建设培训心得,京东商城网站设计,南昌比较好的网站设计一、获取默认的控件模板 WPF修改控件模板是修改外观最方便的方式#xff0c;但是会出现不知道原来的控件的模板长什么样#xff0c;或者如何在原有控件模板上修改的#xff0c;下面就分享了获取某控件默认控件模板的方法#xff08;以控件Button为例#xff09;#xff…一、获取默认的控件模板 WPF修改控件模板是修改外观最方便的方式但是会出现不知道原来的控件的模板长什么样或者如何在原有控件模板上修改的下面就分享了获取某控件默认控件模板的方法以控件Button为例 1、创建一个Button 2、在界面上选择Button右键-编辑模板-编辑副本 就可以在XAML中看到自动生成的原始的控件模板代码 3、可以在默认模板上修改其中的一些属性并运行查看修改效果 这样在生成的默认控件模板上修改需要修改的部分即可可以大大减少工作量也提高了容错率。默认情况下所有的模板和样式都放在主界面的XAML中代码量会很多、很乱我们可以使用单独的资源词典来存放这些模板和样式主界面只要根据Key调用即可。 二、资源字典的使用 1、选中项目右键-添加-新建项-资源词典(WPF) 生成的初始资源词典如下 ResourceDictionary xmlnshttp://schemas.microsoft.com/winfx/2006/xaml/presentationxmlns:xhttp://schemas.microsoft.com/winfx/2006/xamlxmlns:localclr-namespace:TemplateDemo /ResourceDictionary 现在可以将模板和样式作为资源分流到各个资源词典中了。我们现在演示将Button的默认模板转移至该控件模板 ResourceDictionary xmlnshttp://schemas.microsoft.com/winfx/2006/xaml/presentationxmlns:xhttp://schemas.microsoft.com/winfx/2006/xamlxmlns:localclr-namespace:TemplateDemoResourceDictionary.MergedDictionariesResourceDictionaryStyle x:KeyFocusVisualSetter PropertyControl.TemplateSetter.ValueControlTemplateRectangle Margin2 SnapsToDevicePixelstrue Stroke{DynamicResource {x:Static SystemColors.ControlTextBrushKey}} StrokeThickness1 StrokeDashArray1 2//ControlTemplate/Setter.Value/Setter/StyleSolidColorBrush x:KeyButton.Static.Background Color#FFDDDDDD/SolidColorBrush x:KeyButton.Static.Border Color#FF707070/SolidColorBrush x:KeyButton.MouseOver.Background Color#FFBEE6FD/SolidColorBrush x:KeyButton.MouseOver.Border Color#FF3C7FB1/SolidColorBrush x:KeyButton.Pressed.Background Color#FFC4E5F6/SolidColorBrush x:KeyButton.Pressed.Border Color#FF2C628B/SolidColorBrush x:KeyButton.Disabled.Background Color#FFF4F4F4/SolidColorBrush x:KeyButton.Disabled.Border Color#FFADB2B5/SolidColorBrush x:KeyButton.Disabled.Foreground Color#FF838383/Style x:KeyButtonStyle1 TargetType{x:Type Button}Setter PropertyFocusVisualStyle Value{StaticResource FocusVisual}/Setter PropertyBackground Value{StaticResource Button.Static.Background}/Setter PropertyBorderBrush Value{StaticResource Button.Static.Border}/Setter PropertyForeground Value{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}/Setter PropertyBorderThickness Value1/Setter PropertyHorizontalContentAlignment ValueCenter/Setter PropertyVerticalContentAlignment ValueCenter/Setter PropertyPadding Value1/Setter PropertyTemplateSetter.ValueControlTemplate TargetType{x:Type Button}StackPanelBorder x:Nameborder BorderBrush{TemplateBinding BorderBrush} BorderThickness{TemplateBinding BorderThickness} Background{TemplateBinding Background} SnapsToDevicePixelstrueContentPresenter x:NamecontentPresenter FocusableFalse HorizontalAlignment{TemplateBinding HorizontalContentAlignment} Margin{TemplateBinding Padding} RecognizesAccessKeyTrue SnapsToDevicePixels{TemplateBinding SnapsToDevicePixels} VerticalAlignment{TemplateBinding VerticalContentAlignment}//Border/StackPanelControlTemplate.TriggersTrigger PropertyIsDefaulted ValuetrueSetter PropertyBorderBrush TargetNameborder Value{DynamicResource {x:Static SystemColors.HighlightBrushKey}}//TriggerTrigger PropertyIsMouseOver ValuetrueSetter PropertyBackground TargetNameborder Value{StaticResource Button.MouseOver.Background}/Setter PropertyBorderBrush TargetNameborder Value{StaticResource Button.MouseOver.Border}//TriggerTrigger PropertyIsPressed ValuetrueSetter PropertyBackground TargetNameborder Value{StaticResource Button.Pressed.Background}/Setter PropertyBorderBrush TargetNameborder Value{StaticResource Button.Pressed.Border}//TriggerTrigger PropertyIsEnabled ValuefalseSetter PropertyBackground TargetNameborder Value{StaticResource Button.Disabled.Background}/Setter PropertyBorderBrush TargetNameborder Value{StaticResource Button.Disabled.Border}/Setter PropertyTextElement.Foreground TargetNamecontentPresenter Value{StaticResource Button.Disabled.Foreground}//Trigger/ControlTemplate.Triggers/ControlTemplate/Setter.Value/Setter/Style/ResourceDictionary/ResourceDictionary.MergedDictionaries /ResourceDictionary 2、要使用该资源字典还需要在App.Xaml中进行声明我的名称叫TemplateDictionary.xaml需要保证其命名空间一致 Application.ResourcesResourceDictionary SourceTemplateDictionary.xaml/ResourceDictionary/Application.Resources 3、在主XAML中使用StaticResource或DynamicResource进行静态或动态引用即可 Button x:Namebutton ContentButton HorizontalAlignmentLeft Margin309,286,0,0 VerticalAlignmentTop Width75 Style{StaticResource ButtonStyle1}/ 以上就是关于获取默认空间模板和使用资源词典的一些简单的介绍结合起来使用可以搭建简洁方便的代码布局
http://www.yutouwan.com/news/189314/

相关文章:

  • 网站建站套餐以下什么是网络营销的特点
  • 简述seo对各类网站的作用公司的网站制作
  • 医疗不可以做网站网站建设方案及报
  • 宝山网站建设公司怎么给自己的网站做模版
  • 网站设置qq临时会话爱用建站官网
  • 网站建设维护面试非标准零加工
  • 网站设计公司有用吗wordpress 页面文件
  • 做网站手机网站建设创意
  • 建立平台网站要多久河南工程项目信息
  • 聊城网站建设费用软件工程专业招聘网站
  • 六盘水合肥电商网站建设天津智能网站建设制作
  • h5网站是什么意思wordpress阅读式主题
  • 长寿网站建设公司上海企业服务云定位
  • 做网站像素大小商机创业网2021创业
  • 网站策划哪里找郑州做网站推广电
  • 外贸网站建设行业发展平面设计公司经营范围
  • 网站开发主要技术石家庄+外贸网站建设公司
  • 青岛建站费用e4a怎么做网站app
  • 自己做网站视频教程公司网站开发费分录是
  • 网站备案的时间上海建设工程标准与造价信息网站
  • 手机网站开发前台架构网站 后台
  • 论坛网站开发的意义成都微信小程序定制
  • 小蚁人网站建设石家庄网站建设远策科技
  • 视频制作教程自学关键词自动优化
  • 最超值的郑州网站建设软件开发培训班排名前十名
  • 阿里巴巴国际站入驻大连网站设计策划
  • 昌吉做58网站的江苏品牌网站建设电话
  • 积玉桥网站建设wordpress项目下载文件
  • 交易平台网站模板学校网站建设情况介绍
  • 新手做网站盈利免费网站软件推荐正能量