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

广州萝岗区网站建设app应用开发在哪里找

广州萝岗区网站建设,app应用开发在哪里找,推广app下载,做图挣钱的网站WPF实现一个带旋转动画的菜单栏 一、创建WPF项目及文件1、创建项目2、创建文件夹及文件3、添加引用 二、代码实现2.ControlAttachProperty类 一、创建WPF项目及文件 1、创建项目 打开VS2022,创建一个WPF项目#xff0c;如下所示 2、创建文件夹及文件 创建资源文件夹… WPF实现一个带旋转动画的菜单栏 一、创建WPF项目及文件1、创建项目2、创建文件夹及文件3、添加引用 二、代码实现2.ControlAttachProperty类 一、创建WPF项目及文件 1、创建项目 打开VS2022,创建一个WPF项目如下所示 2、创建文件夹及文件 创建资源文件夹添加字体图标文件添加 Menu样式文件如下所示 创建公共附加属性用控件类库,并创建对应的 ControlAttachProperty 类文件如下 3、添加引用 右键 Menu_WPF 添加引用将类库引用到当前项目 二、代码实现 2.ControlAttachProperty类 代码如下示例 using Microsoft.Win32; using System; using System.Windows; using System.Windows.Controls; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using CheckBox System.Windows.Controls.CheckBox; using ComboBox System.Windows.Controls.ComboBox; using OpenFileDialog Microsoft.Win32.OpenFileDialog; using RadioButton System.Windows.Controls.RadioButton; using RichTextBox System.Windows.Controls.RichTextBox; using TextBox System.Windows.Controls.TextBox;namespace Common.UserControl.Extession {/// summary/// 公共附加属性/// /summarypublic static class ControlAttachProperty{#region FocusBorderBrush 焦点边框色输入控件public static readonly DependencyProperty FocusBorderBrushProperty DependencyProperty.RegisterAttached(FocusBorderBrush, typeof(Brush), typeof(ControlAttachProperty), new FrameworkPropertyMetadata(null));public static void SetFocusBorderBrush(DependencyObject element, Brush value){element.SetValue(FocusBorderBrushProperty, value);}public static Brush GetFocusBorderBrush(DependencyObject element){return (Brush)element.GetValue(FocusBorderBrushProperty);}#endregion#region MouseOverBorderBrush 鼠标进入边框色输入控件public static readonly DependencyProperty MouseOverBorderBrushProperty DependencyProperty.RegisterAttached(MouseOverBorderBrush, typeof(Brush), typeof(ControlAttachProperty),new FrameworkPropertyMetadata(Brushes.Transparent,FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.Inherits));/// summary/// Sets the brush used to draw the mouse over brush./// /summarypublic static void SetMouseOverBorderBrush(DependencyObject obj, Brush value){obj.SetValue(MouseOverBorderBrushProperty, value);}/// summary/// Gets the brush used to draw the mouse over brush./// /summary[AttachedPropertyBrowsableForType(typeof(TextBox))][AttachedPropertyBrowsableForType(typeof(CheckBox))][AttachedPropertyBrowsableForType(typeof(RadioButton))][AttachedPropertyBrowsableForType(typeof(DatePicker))][AttachedPropertyBrowsableForType(typeof(ComboBox))][AttachedPropertyBrowsableForType(typeof(RichTextBox))]public static Brush GetMouseOverBorderBrush(DependencyObject obj){return (Brush)obj.GetValue(MouseOverBorderBrushProperty);}#endregion#region AttachContentProperty 附加组件模板/// summary/// 附加组件模板/// /summarypublic static readonly DependencyProperty AttachContentProperty DependencyProperty.RegisterAttached(AttachContent, typeof(ControlTemplate), typeof(ControlAttachProperty), new FrameworkPropertyMetadata(null));public static ControlTemplate GetAttachContent(DependencyObject d){return (ControlTemplate)d.GetValue(AttachContentProperty);}public static void SetAttachContent(DependencyObject obj, ControlTemplate value){obj.SetValue(AttachContentProperty, value);}#endregion#region WatermarkProperty 水印/// summary/// 水印/// /summarypublic static readonly DependencyProperty WatermarkProperty DependencyProperty.RegisterAttached(Watermark, typeof(string), typeof(ControlAttachProperty), new FrameworkPropertyMetadata());public static string GetWatermark(DependencyObject d){return (string)d.GetValue(WatermarkProperty);}public static void SetWatermark(DependencyObject obj, string value){obj.SetValue(WatermarkProperty, value);}#endregion#region FIconProperty 字体图标/// summary/// 字体图标/// /summarypublic static readonly DependencyProperty FIconProperty DependencyProperty.RegisterAttached(FIcon, typeof(string), typeof(ControlAttachProperty), new FrameworkPropertyMetadata());public static string GetFIcon(DependencyObject d){return (string)d.GetValue(FIconProperty);}public static void SetFIcon(DependencyObject obj, string value){obj.SetValue(FIconProperty, value);}#endregion#region FIconSizeProperty 字体图标大小/// summary/// 字体图标/// /summarypublic static readonly DependencyProperty FIconSizeProperty DependencyProperty.RegisterAttached(FIconSize, typeof(double), typeof(ControlAttachProperty), new FrameworkPropertyMetadata(12D));public static double GetFIconSize(DependencyObject d){return (double)d.GetValue(FIconSizeProperty);}public static void SetFIconSize(DependencyObject obj, double value){obj.SetValue(FIconSizeProperty, value);}#endregion#region FIconMarginProperty 字体图标边距/// summary/// 字体图标/// /summarypublic static readonly DependencyProperty FIconMarginProperty DependencyProperty.RegisterAttached(FIconMargin, typeof(Thickness), typeof(ControlAttachProperty), new FrameworkPropertyMetadata(null));public static Thickness GetFIconMargin(DependencyObject d){return (Thickness)d.GetValue(FIconMarginProperty);}public static void SetFIconMargin(DependencyObject obj, Thickness value){obj.SetValue(FIconMarginProperty, value);}#endregion#region AllowsAnimationProperty 启用旋转动画/// summary/// 启用旋转动画/// /summarypublic static readonly DependencyProperty AllowsAnimationProperty DependencyProperty.RegisterAttached(AllowsAnimation, typeof(bool), typeof(ControlAttachProperty), new FrameworkPropertyMetadata(false, AllowsAnimationChanged));public static bool GetAllowsAnimation(DependencyObject d){return (bool)d.GetValue(AllowsAnimationProperty);}public static void SetAllowsAnimation(DependencyObject obj, bool value){obj.SetValue(AllowsAnimationProperty, value);}/// summary/// 旋转动画刻度/// /summaryprivate static DoubleAnimation RotateAnimation new DoubleAnimation(0, new Duration(TimeSpan.FromMilliseconds(200)));/// summary/// 绑定动画事件/// /summaryprivate static void AllowsAnimationChanged(DependencyObject d, DependencyPropertyChangedEventArgs e){var uc d as FrameworkElement;if (uc null) return;if (uc.RenderTransformOrigin new Point(0, 0)){uc.RenderTransformOrigin new Point(0.5, 0.5);RotateTransform trans new RotateTransform(0);uc.RenderTransform trans;}var value (bool)e.NewValue;if (value){RotateAnimation.To 180;uc.RenderTransform.BeginAnimation(RotateTransform.AngleProperty, RotateAnimation);}else{RotateAnimation.To 0;uc.RenderTransform.BeginAnimation(RotateTransform.AngleProperty, RotateAnimation);}}#endregion#region CornerRadiusProperty Border圆角/// summary/// Border圆角/// /summarypublic static readonly DependencyProperty CornerRadiusProperty DependencyProperty.RegisterAttached(CornerRadius, typeof(CornerRadius), typeof(ControlAttachProperty), new FrameworkPropertyMetadata(null));public static CornerRadius GetCornerRadius(DependencyObject d){return (CornerRadius)d.GetValue(CornerRadiusProperty);}public static void SetCornerRadius(DependencyObject obj, CornerRadius value){obj.SetValue(CornerRadiusProperty, value);}#endregion#region LabelProperty TextBox的头部Label/// summary/// TextBox的头部Label/// /summarypublic static readonly DependencyProperty LabelProperty DependencyProperty.RegisterAttached(Label, typeof(string), typeof(ControlAttachProperty), new FrameworkPropertyMetadata(null));[AttachedPropertyBrowsableForType(typeof(TextBox))]public static string GetLabel(DependencyObject d){return (string)d.GetValue(LabelProperty);}public static void SetLabel(DependencyObject obj, string value){obj.SetValue(LabelProperty, value);}#endregion#region LabelTemplateProperty TextBox的头部Label模板/// summary/// TextBox的头部Label模板/// /summarypublic static readonly DependencyProperty LabelTemplateProperty DependencyProperty.RegisterAttached(LabelTemplate, typeof(ControlTemplate), typeof(ControlAttachProperty), new FrameworkPropertyMetadata(null));[AttachedPropertyBrowsableForType(typeof(TextBox))]public static ControlTemplate GetLabelTemplate(DependencyObject d){return (ControlTemplate)d.GetValue(LabelTemplateProperty);}public static void SetLabelTemplate(DependencyObject obj, ControlTemplate value){obj.SetValue(LabelTemplateProperty, value);}#endregion} } Menu样式文件实现 !--背景透明的HeaderItem样式,带旋转动画--Style x:KeyTransparentHeaderMenuItem TargetType{x:Type MenuItem}Setter PropertyBorderBrush Value{StaticResource MenuBorderBrush}/Setter PropertyBorderThickness Value1/Setter PropertyBackground Value{StaticResource MenuBackground}/Setter PropertyForeground Value{StaticResource TextForeground}/Setter PropertyFontSize Value{StaticResource FontSize}/Setter PropertyMargin Value2,0,2,0/Setter PropertyHeight Value30/Setter Propertylocal:ControlAttachProperty.FIconSize Value18/Setter PropertyTemplateSetter.ValueControlTemplate TargetType{x:Type MenuItem}Grid x:NameBg VerticalAlignment{TemplateBinding VerticalAlignment}StackPanel OrientationHorizontal x:Nameborder VerticalAlignmentCenter HorizontalAlignment{TemplateBinding HorizontalContentAlignment}!--icon--TextBlock x:NamePART_Icon Text{TemplateBinding Icon} Foreground{TemplateBinding Foreground} local:ControlAttachProperty.AllowsAnimation{Binding IsSubmenuOpen,RelativeSource{RelativeSource TemplatedParent}}FontSize{TemplateBinding local:ControlAttachProperty.FIconSize} Style{StaticResource FIcon} /TextBlock x:NametxtHeader Margin5 0 0 0 FontSize{TemplateBinding FontSize} HorizontalAlignmentStretch Text{TemplateBinding Header} VerticalAlignmentCenter Grid.Column1 Foreground{TemplateBinding Foreground}//StackPanel!--弹出子集菜单容器--Popup x:NameSubMenuPopup AllowsTransparencytrue IsOpen{Binding IsSubmenuOpen, RelativeSource{RelativeSource TemplatedParent}} PlacementBottom Focusablefalse VerticalOffset0PopupAnimation{DynamicResource {x:Static SystemParameters.MenuPopupAnimationKey}}Border Background{TemplateBinding Background} CornerRadius0 Margin5 Effect{StaticResource DefaultDropShadow}BorderBrush{TemplateBinding BorderBrush} BorderThickness{TemplateBinding BorderThickness}Grid x:NameSubMenu Grid.IsSharedSizeScopeTrueStackPanel Margin10 IsItemsHostTrue KeyboardNavigation.DirectionalNavigationCycle//Grid/Border/Popup/Grid!--触发器--ControlTemplate.Triggers!--高亮状态--Trigger PropertyIsHighlighted ValuetrueSetter PropertyForeground Value{StaticResource MouseOverForeground}/Setter/TriggerTrigger PropertyIsPressed ValuetrueSetter PropertyForeground Value{StaticResource PressedForeground}/Setter/TriggerTrigger PropertyIsEnabled ValueFalseSetter TargetNameborder Value{StaticResource DisableOpacity} PropertyOpacity/Setter/Trigger/ControlTemplate.Triggers/ControlTemplate/Setter.Value/Setter/Style MainWindow样式实现 Menu Width80 Height30 Margin3 BackgroundTransparent MenuItem Header展开菜单 Style{StaticResource TransparentHeaderMenuItem} Padding0 Icon#xe61b; MenuItem Style{StaticResource TransparentHeaderMenuItem} Icon#xe605; Header设置 /MenuItem Style{StaticResource TransparentHeaderMenuItem} Icon#xe656; Header插件管理 /MenuItem Style{StaticResource TransparentHeaderMenuItem} Icon#xe65e; Header用户管理 /MenuItem Style{StaticResource TransparentHeaderMenuItem} Icon#xe659; Header修改密码 /MenuItem Style{StaticResource TransparentHeaderMenuItem} Icon#xe7c6; Header在线更新 /Separator BackgroundSpringGreen Style{StaticResource HorizontalSeparatorStyle}/MenuItem Style{StaticResource TransparentHeaderMenuItem} Icon#xe6d5; Header问题反馈 /MenuItem Style{StaticResource TransparentHeaderMenuItem} Icon#xe65f; Header技术支持 /MenuItem Style{StaticResource TransparentHeaderMenuItem} Icon#xe600; Header帮助 /MenuItem Style{StaticResource TransparentHeaderMenuItem} Icon#xe622; Header关于 //MenuItem/Menu
http://www.w-s-a.com/news/83762/

相关文章:

  • 六安网站建设价格做网站好吗
  • 中小企业网站建设咨询湖南省邵阳建设局网站
  • 分类网站一天做几条合适南安网络推广
  • 案例学 网页设计与网站建设百度竞价关键词出价技巧
  • 做公司网站要那些资料南雄网站建设
  • 自己做的网站发布到网上视频播放不了网页游戏奥奇传说
  • 网站效果用什么软件做品牌网站建设等高端服务
  • 四川省成华区建设局网站网站专业制作
  • 网站建设如何开票网站后台怎么做超链接
  • 教育网站设计方案建设网站技术公司电话号码
  • 建网站要定制还是第三方系统传奇网站模板psd
  • 免费搭建企业网站什么叫网站定位
  • 网站建设cms程序员培训班
  • 网站seo技术wordpress editor ios
  • 红酒网站设计成立公司需要哪些手续
  • 广州做网站哪个好网站建网站建设网站站网站
  • 如何快速提升网站pr短剧个人主页简介模板
  • 上海网站建设 永灿百度权重3的网站值多少
  • 公司展示网站模板模板工
  • 网站建设收费详情舟山公司做网站
  • 深圳宝安区住房和建设局网站html模板大全
  • 和田哪里有做网站的地方wordpress地址更改
  • 恒通建设集团有限公司网站企业网站百度指数多少算竞争大
  • 雅虎网站收录提交入口如何使用wordpress搭建网站
  • 微商城网站建设怎么样发稿是什么意思
  • dz建站与wordpress群晖做网站服务器速度快吗
  • 做手机网站的公司网站建设 app开发 图片
  • 网站开发技术背景介绍wordpress数据库重置密码
  • 开发建设网站的实施过程是一个logo设计品牌
  • 做360pc网站排名首页工程造价信息网官网首页