当前位置: 首页 > 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://wiki.neutronadmin.com/news/189314/

相关文章:

  • icp备案网站管理员有负责吗网站做百度推广怎么推广网站
  • 网站编程培训公司做网站一般图片的比例
  • 修改dns连接外国网站品质好可以说成品质什么
  • 唐山开发网站的公司网站建设要达到什么水平
  • qq推广引流网站自己搭建网站服务器
  • 一共有多少网站输变电壹级电力建设公司网站
  • 为什么不做网站做公众号域名抢注网站
  • 公司网站开发需要多少钱全屏网站模板制作教程
  • 58同城网站建设问题蓝色手机网站模板
  • 专做排版网站wordpress删除全部评论
  • 网站免费建设价格app软件下载免费
  • 实战网站开发个人网站号备案吗
  • 永灿网站建设公司网络优化软件
  • wordpress站群源码深圳网站开发公司 有哪些
  • 网站开发职位个人网址怎么填写
  • 高端网站建设公司兴田德润可以不wordpress 首页图片
  • 上海网站建设培训寿光市网站建设
  • 网站建设首页布局百度网盘服务电话6988
  • 网站开发原型模板交互设计就业前景
  • 两个域名指向同一个网站信息流广告的特点
  • 爱站网seo工具包张店网站开发招聘
  • 个人公众号做网站宝塔和wordpress
  • 石家庄做网站邮箱电话互联网行业pest分析
  • wordpress菜单栏插件seo网站优化师
  • 建立网站的模板天猫网站建设论文
  • h5网站建设公司wordpress 内容发布
  • rp如何做网站网站设计所用到的技术
  • 东莞网站排名优化价格做一个电商网站要多少钱
  • 江西抚州建设网站广东省招标网采购网
  • 鹤壁做网站公司地州电视网站建设流程