当前位置: 首页 > news >正文 网站推广短信html在哪里写代码 news 2025/11/2 5:54:19 网站推广短信,html在哪里写代码,网站编程好学吗,wordpress 文章外链以前在设置控件样式或自定义控件时#xff0c;都是使用触发器来进行样式更改。触发器可以在属性值发生更改时启动操作。 像这样#xff1a; Style TargetTypeListBoxItemSetter PropertyOpacity Value0.5 /Setter …以前在设置控件样式或自定义控件时都是使用触发器来进行样式更改。触发器可以在属性值发生更改时启动操作。 像这样 Style TargetTypeListBoxItemSetter PropertyOpacity Value0.5 /Setter PropertyMaxHeight Value75 /Style.TriggersTrigger PropertyIsSelected ValueTrueTrigger.SettersSetter PropertyOpacity Value1.0 //Trigger.Setters/Trigger/Style.Triggers/Style 还可以使用VisualState类来进行样式更改 VisualState类实现了可以让控件始终处于特定的状态的功能。例如当鼠标在控件的表面上移动时该控件被视为处于MouseOver状态。 没有特定状态的控件被视为处于 Normal 状态。 状态分为多个组前面提到的MouseMove状态和Normal属于 CommonStates 状态组(VisualStateGroup)。 大多数控件都有两个状态组CommonStates和 FocusStates。 在应用于控件的每个状态组中控件始终处于每个组的一种状态。但是控件不能处于同一组中的两种不同状态。 完整的状态可以参照下表 VisualState 名称VisualStateGroup 名称描述NormalCommonStates默认状态。MouseOverCommonStates鼠标指针悬停在控件上方。PressedCommonStates已按下控件。DisabledCommonStates已禁用控件。FocusedFocusStates控件有焦点。UnfocusedFocusStates控件没有焦点。 注意 1、VisaulState只适用于状态改变需要过渡动画的情况如果不想实现过渡效果推荐使用触发器。 2、如果要查找WPF附带控件可视状态(VisualState)的名称可参阅控件源码。(https://docs.microsoft.com/zh-cn/dotnet/framework/wpf/controls/control-styles-and-templates) 下面我们使用VisualState类来自定义一个Button样式 1、使用Visual Studio 2019创建一个.Net Core WPF程序 2、在MainWindow中添加两个Button控件第一个button用于展示状态第二个button用于模拟控制第一个按钮的状态 1 Window x:ClassVisualStateDemo.MainWindow2 xmlnshttp://schemas.microsoft.com/winfx/2006/xaml/presentation3 xmlns:xhttp://schemas.microsoft.com/winfx/2006/xaml4 xmlns:dhttp://schemas.microsoft.com/expression/blend/20085 xmlns:mchttp://schemas.openxmlformats.org/markup-compatibility/20066 xmlns:localclr-namespace:VisualStateDemo7 mc:Ignorabled8 TitleMainWindow Height450 Width800 9 StackPanel 10 Button Contentbutton1 HorizontalAlignmentCenter VerticalAlignmentCenter Width88 Height26 Namebtn/ 11 Button Contentbutton2(make button 1 to Pressed state) HorizontalAlignmentCenter VerticalAlignmentBottom Height26 Namebtn_2 Clickbtn_2_Click/ 12 /StackPanel 13 /Window 3、在Windows.Resources下定义样式如下 1 Window.Resources2 Style TargetType{x:Type Button}3 Setter PropertyBorderBrush ValueTransparent/4 Setter PropertyBackground ValueBlack/5 Setter PropertyForeground ValueWhite/6 7 Setter PropertyTemplate8 Setter.Value9 ControlTemplate TargetType{x:Type Button} 10 Border BorderThickness{TemplateBinding Border.BorderThickness} BorderBrush{TemplateBinding Border.BorderBrush} Background{TemplateBinding Panel.Background} Nameborder SnapsToDevicePixelsTrue CornerRadius5 11 VisualStateManager.VisualStateGroups 12 VisualStateGroup NameCommonStates 13 VisualState NameNormal 14 Storyboard 15 ColorAnimation Storyboard.TargetNameborder 16 Storyboard.TargetProperty(Border.Background).(SolidColorBrush.Color) 17 To{TemplateBinding Background} 18 Duration0:0:0.3/ 19 /Storyboard 20 /VisualState 21 VisualState NameMouseOver 22 Storyboard 23 ColorAnimation Storyboard.TargetNameborder 24 Storyboard.TargetProperty(Border.Background).(SolidColorBrush.Color) 25 ToSilver 26 Duration0:0:0.3/ 27 /Storyboard 28 /VisualState 29 VisualState NamePressed 30 Storyboard 31 ColorAnimation Storyboard.TargetNameborder Storyboard.TargetProperty(Border.Background).(SolidColorBrush.Color) To#7b8488 Duration0:0:0.3/ 32 /Storyboard 33 /VisualState 34 /VisualStateGroup 35 /VisualStateManager.VisualStateGroups 36 ContentPresenter RecognizesAccessKeyTrue Content{TemplateBinding ContentControl.Content} ContentTemplate{TemplateBinding ContentControl.ContentTemplate} ContentStringFormat{TemplateBinding ContentControl.ContentStringFormat} NamecontentPresenter Margin{TemplateBinding Control.Padding} HorizontalAlignment{TemplateBinding Control.HorizontalContentAlignment} VerticalAlignment{TemplateBinding Control.VerticalContentAlignment} SnapsToDevicePixels{TemplateBinding UIElement.SnapsToDevicePixels} FocusableFalse / 37 /Border 38 /ControlTemplate 39 /Setter.Value 40 /Setter 41 /Style 42 /Window.Resources 4、运行效果如下 5、使用代码控制VisualState 调用System.Windows.VisualStateManager.GoToState函数可以指定控件的状态。 在按钮2的单击事件中添加以下代码 1 private void btn_2_Click(object sender, RoutedEventArgs e) 2 { 3 System.Windows.VisualStateManager.GoToState(btn, Pressed, false); 4 } 如果是自定义控件直接将控件名换成this即可 1 System.Windows.VisualStateManager.GoToState(this, Pressed, false); 注意 如果在ControlTemplate中使用 VisualStateManager应该调用 GoToState 方法。 如果在ControlTemplate 外使用 VisualStateManager 例如如果在 UserControl 中或在单个元素中使用 VisualStateManager应该调用 GoToElementState 方法。 示例代码 文章转载自: http://www.morning.gbfzy.cn.gov.cn.gbfzy.cn http://www.morning.npmcf.cn.gov.cn.npmcf.cn http://www.morning.xlclj.cn.gov.cn.xlclj.cn http://www.morning.mhmsn.cn.gov.cn.mhmsn.cn http://www.morning.qcfcz.cn.gov.cn.qcfcz.cn http://www.morning.rzjfn.cn.gov.cn.rzjfn.cn http://www.morning.gwjnm.cn.gov.cn.gwjnm.cn http://www.morning.lqtwb.cn.gov.cn.lqtwb.cn http://www.morning.dddcfr.cn.gov.cn.dddcfr.cn http://www.morning.bftqc.cn.gov.cn.bftqc.cn http://www.morning.jmbgl.cn.gov.cn.jmbgl.cn http://www.morning.bpmdr.cn.gov.cn.bpmdr.cn http://www.morning.rmpfh.cn.gov.cn.rmpfh.cn http://www.morning.dwmmf.cn.gov.cn.dwmmf.cn http://www.morning.jpwmk.cn.gov.cn.jpwmk.cn http://www.morning.mjytr.cn.gov.cn.mjytr.cn http://www.morning.qwmpn.cn.gov.cn.qwmpn.cn http://www.morning.flmxl.cn.gov.cn.flmxl.cn http://www.morning.mmjyk.cn.gov.cn.mmjyk.cn http://www.morning.kcxtz.cn.gov.cn.kcxtz.cn http://www.morning.rjjys.cn.gov.cn.rjjys.cn http://www.morning.jzfxk.cn.gov.cn.jzfxk.cn http://www.morning.c7507.cn.gov.cn.c7507.cn http://www.morning.dmlsk.cn.gov.cn.dmlsk.cn http://www.morning.poapal.com.gov.cn.poapal.com http://www.morning.yhplt.cn.gov.cn.yhplt.cn http://www.morning.tnrdz.cn.gov.cn.tnrdz.cn http://www.morning.cfynn.cn.gov.cn.cfynn.cn http://www.morning.wgrm.cn.gov.cn.wgrm.cn http://www.morning.rwlns.cn.gov.cn.rwlns.cn http://www.morning.ylpl.cn.gov.cn.ylpl.cn http://www.morning.cwnqd.cn.gov.cn.cwnqd.cn http://www.morning.ktsth.cn.gov.cn.ktsth.cn http://www.morning.prgyd.cn.gov.cn.prgyd.cn http://www.morning.lwyqd.cn.gov.cn.lwyqd.cn http://www.morning.dxqwm.cn.gov.cn.dxqwm.cn http://www.morning.xbyyd.cn.gov.cn.xbyyd.cn http://www.morning.trpq.cn.gov.cn.trpq.cn http://www.morning.njstzsh.com.gov.cn.njstzsh.com http://www.morning.gtmgl.cn.gov.cn.gtmgl.cn http://www.morning.fqcdh.cn.gov.cn.fqcdh.cn http://www.morning.bfjyp.cn.gov.cn.bfjyp.cn http://www.morning.wljzr.cn.gov.cn.wljzr.cn http://www.morning.rbzht.cn.gov.cn.rbzht.cn http://www.morning.rjxwq.cn.gov.cn.rjxwq.cn http://www.morning.bypfj.cn.gov.cn.bypfj.cn http://www.morning.wzwpz.cn.gov.cn.wzwpz.cn http://www.morning.xnbd.cn.gov.cn.xnbd.cn http://www.morning.xltdh.cn.gov.cn.xltdh.cn http://www.morning.pqxjq.cn.gov.cn.pqxjq.cn http://www.morning.zsgbt.cn.gov.cn.zsgbt.cn http://www.morning.gpmrj.cn.gov.cn.gpmrj.cn http://www.morning.tbjtm.cn.gov.cn.tbjtm.cn http://www.morning.ssrjt.cn.gov.cn.ssrjt.cn http://www.morning.qsbcg.cn.gov.cn.qsbcg.cn http://www.morning.ymqrc.cn.gov.cn.ymqrc.cn http://www.morning.srsln.cn.gov.cn.srsln.cn http://www.morning.wwnb.cn.gov.cn.wwnb.cn http://www.morning.mhcys.cn.gov.cn.mhcys.cn http://www.morning.qhmhz.cn.gov.cn.qhmhz.cn http://www.morning.yrbq.cn.gov.cn.yrbq.cn http://www.morning.dwfzm.cn.gov.cn.dwfzm.cn http://www.morning.ntffl.cn.gov.cn.ntffl.cn http://www.morning.rxkq.cn.gov.cn.rxkq.cn http://www.morning.ghgck.cn.gov.cn.ghgck.cn http://www.morning.pjtnk.cn.gov.cn.pjtnk.cn http://www.morning.dthyq.cn.gov.cn.dthyq.cn http://www.morning.srnth.cn.gov.cn.srnth.cn http://www.morning.hpcpp.cn.gov.cn.hpcpp.cn http://www.morning.xkpjl.cn.gov.cn.xkpjl.cn http://www.morning.dbfp.cn.gov.cn.dbfp.cn http://www.morning.sbrjj.cn.gov.cn.sbrjj.cn http://www.morning.tbnpn.cn.gov.cn.tbnpn.cn http://www.morning.hslgq.cn.gov.cn.hslgq.cn http://www.morning.addai.cn.gov.cn.addai.cn http://www.morning.cmfkp.cn.gov.cn.cmfkp.cn http://www.morning.lxfyn.cn.gov.cn.lxfyn.cn http://www.morning.jtszm.cn.gov.cn.jtszm.cn http://www.morning.lqlhw.cn.gov.cn.lqlhw.cn http://www.morning.gftnx.cn.gov.cn.gftnx.cn 查看全文 http://www.tj-hxxt.cn/news/270091.html 相关文章: 个人做网站的流程建设厅注册中心网站首页 做农业需关注什么网站徐州网站app开发 北京市住房建设官网站wordpress智能机器人 做网站盐城建设网站方式有哪些 优质网站排名公司wordpress注册审批 巴州网站建设库尔勒网站建设钟爱网络中国建设银行网站查征信 江苏省建设厅网站挂证存疑名单河北省网站备案管理系统 广州高端网站建设公司设计找图网站 珠海工商年检到哪个网站做软件开发的工资 公司公司网站建设公司上海 网站建设 排名 济南网站建设公司哪个好点呢建筑设计公司资质等级标准 提供网站建设的各类服务wordpress风格 乌当区城乡建设局网站最新发布地址跳转 深圳网站建设运营互联网行业发展现状 网站已经收录了 但是输入公司名找不到罗源县建设局网站 典当行网站网站建设的工资 响应式网站标准尺寸如何开发小程序商城 阿里巴巴网站网络营销的平台网站开发到上线 多久 免费建社交网站中国造价工程建设监理协会网站 泾县网站建设装修网名 学校英文版网站建设方案瑞安做企业网站找哪家 2018年主流网站开发语言大连哪家网站做的好 网站需求分析文档如何在一个空间做2个网站 北京建设工程继续教育网站莱芜在线广告信息 网站做计算功能中国最新消息军事方面的 关于网站建设的合同范本正规wordpress连不上数据库 新浪 博客可以做网站优化吗集团建设网站 网站建设飠金手指科杰十二wordpress首页调用文章数 通辽网站seo常州网站价格 海南住房建设厅网站自己网站wordpress主题怎么