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

做网站和做微信小程序网络营销策划方案的目的

做网站和做微信小程序,网络营销策划方案的目的,游戏网站建设平台,能看wap软件文章目录 1、案例运行效果2、项目准备2、功能实现1、控件模板实现2、控件封装1、目录与文件创建2、各文件功能实现 3、开关界面与主窗体菜单实现1、开关界面实现2、主窗体菜单实现 4、源代码获取 1、案例运行效果 2、项目准备 打开项目 Wpf_Examples#xff0c;新建ToggleBut… 文章目录 1、案例运行效果2、项目准备2、功能实现1、控件模板实现2、控件封装1、目录与文件创建2、各文件功能实现 3、开关界面与主窗体菜单实现1、开关界面实现2、主窗体菜单实现 4、源代码获取 1、案例运行效果 2、项目准备 打开项目 Wpf_Examples新建ToggleButtonWindow.xmal 文件,这里没有 Wpf_Examples 项目的可以看下前面章节WPFMVVM案例实战三- 动态数字卡片效果实现 详细介绍了项目创建过程。 2、功能实现 1、控件模板实现 开关按钮基于CheckBox 按钮基础上修改控件模板实现。 ToggleButtonWindow.xaml 界面代码如下 Window x:ClassWpf_Examples.Views.ToggleButtonWindowxmlnshttp://schemas.microsoft.com/winfx/2006/xaml/presentationxmlns:xhttp://schemas.microsoft.com/winfx/2006/xamlxmlns:dhttp://schemas.microsoft.com/expression/blend/2008xmlns:mchttp://schemas.openxmlformats.org/markup-compatibility/2006xmlns:localclr-namespace:Wpf_Examples.Viewsmc:IgnorabledTitleToggleButtonWindow Height450 Width800 Background#2B2B2BWindow.ResourcesStyle x:KeyToggleSwitchStyleChangeAnimate TargetTypeCheckBoxSetter PropertyTemplateSetter.ValueControlTemplate TargetTypeCheckBoxStackPanel OrientationHorizontalGridBorder CornerRadius22 Width80 Height44 BackgroundLightGray/Border CornerRadius18 x:Namebutton Width36 Height36 HorizontalAlignmentLeft//Grid/StackPanelControlTemplate.ResourcesStoryboard x:KeytoLeftStoryboardThicknessAnimation Storyboard.TargetPropertyMargin Storyboard.TargetNamebutton From40,0,0,0 To4,0,0,0 Duration0:0:0:0.3!--增加缓动处理让切换效果更加平滑--ThicknessAnimation.EasingFunctionCubicEase EasingModeEaseInOut//ThicknessAnimation.EasingFunction/ThicknessAnimation/StoryboardStoryboard x:KeytoRightStoryboardThicknessAnimation Storyboard.TargetPropertyMargin Storyboard.TargetNamebutton From4,0,0,0 To40,0,0,0 Duration0:0:0:0.3!--增加缓动处理让切换效果更加平滑--ThicknessAnimation.EasingFunctionCubicEase EasingModeEaseInOut//ThicknessAnimation.EasingFunction/ThicknessAnimation/Storyboard/ControlTemplate.ResourcesControlTemplate.TriggersTrigger PropertyIsChecked ValueFalseTrigger.EnterActionsRemoveStoryboard BeginStoryboardNameright/BeginStoryboard Storyboard{StaticResource toLeftStoryboard} x:Nameleft//Trigger.EnterActionsSetter TargetNamebutton PropertyBackground Value#737373//TriggerTrigger PropertyIsChecked ValueTrueTrigger.EnterActionsRemoveStoryboard BeginStoryboardNameleft/BeginStoryboard Storyboard{StaticResource toRightStoryboard} x:Nameright//Trigger.EnterActionsSetter TargetNamebutton PropertyBackground Value#25DC2D//Trigger/ControlTemplate.Triggers/ControlTemplate/Setter.Value/Setter/Style/Window.ResourcesGrid HorizontalAlignmentCenterCheckBox Style{StaticResource ToggleSwitchStyleChangeAnimate}//Grid /Window 2、控件封装 1、目录与文件创建 首先在自定义控件库 CustomControlLib 中新建一个 ToggleSwitch.cs 文件在创建一个 Converters 文件夹创建 ToggleSwitchConverter.cs 文件这里用来做数据转换使用。如下图所示 2、各文件功能实现 首先我们先实现开关按钮的样式定义将前面 ToggleButtonWindow.xaml 中的 Style 样式拷贝到自定义控件的 Generic.xaml 文件中修改后如下所示 Style TargetType{x:Type local:ToggleSwitch}Setter PropertyTemplateSetter.ValueControlTemplate TargetTypeCheckBoxStackPanel OrientationHorizontalGridBorder Width{TemplateBinding Width} Height{TemplateBinding Height} CornerRadius{TemplateBinding Height,Converter{StaticResource ToggleSwitchConverter},ConverterParameterOutSideCorner}BackgroundLightGray/Border x:Namebutton CornerRadius{TemplateBinding Height,Converter{StaticResource ToggleSwitchConverter},ConverterParameterInSideCorner}Width{TemplateBinding Height,Converter{StaticResource ToggleSwitchConverter},ConverterParameterButtonSize}Height{TemplateBinding Height,Converter{StaticResource ToggleSwitchConverter},ConverterParameterButtonSize}HorizontalAlignmentLeft//Grid/StackPanelControlTemplate.TriggersTrigger PropertyIsChecked ValueFalseSetter TargetNamebutton PropertyBackground Value#737373//TriggerTrigger PropertyIsChecked ValueTrueSetter TargetNamebutton PropertyBackground Value{Binding Foreground,RelativeSource{RelativeSource TemplatedParent}}//Trigger/ControlTemplate.Triggers/ControlTemplate/Setter.Value/Setter /Style样式代码主要是把按钮的宽高数据值绑定到原有按钮宽高属性上通过转换器完成不同属性数据值的不同赋值然后我们实现转换器 ToggleSwitchConverter.cs 的代码如下所示 public class ToggleSwitchConverter : IValueConverter {public object Convert(object value, Type targetType, object parameter, CultureInfo culture){if (value is double height){var property parameter as string;switch (property){case ButtonSize:return (height - 8);case OutSideCorner:return new CornerRadius(height/2);case InSideCorner:return new CornerRadius((height-8) / 2);}}throw new NotImplementedException();}public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture){throw new NotImplementedException();} }最后,我们在 ToggleSwitch.cs 实现按钮的切换和动画加载功能代码ToggleSwitch.cs 代码实现如下 public class ToggleSwitch:CheckBox {static ToggleSwitch(){DefaultStyleKeyProperty.OverrideMetadata(typeof(ToggleSwitch), new FrameworkPropertyMetadata(typeof(ToggleSwitch)));}public ToggleSwitch(){Checked ToggleSwitch_Checked;Unchecked ToggleSwitch_Unchecked;}private void ToggleSwitch_Checked(object sender, RoutedEventArgs e){Animatebutton(true);}private void ToggleSwitch_Unchecked(object sender, RoutedEventArgs e){Animatebutton(false);}private void Animatebutton(bool isChecked){if (GetTemplateChild(button) is Border button){Storyboard storyboard new Storyboard();ThicknessAnimation animation new ThicknessAnimation();animation.Durationnew Duration (TimeSpan.FromSeconds(0.3));animation.EasingFunctionnew CircleEase { EasingMode EasingMode.EaseOut };if (isChecked){animation.From new Thickness(4, 0, 0, 0);animation.Tonew Thickness(ActualWidth-(ActualHeight-8)-4, 0, 0, 0);}else{animation.To new Thickness(4, 0, 0, 0);animation.From new Thickness(ActualWidth - (ActualHeight - 8) - 4, 0, 0, 0);}Storyboard.SetTarget(animation,button); Storyboard.SetTargetProperty(animation,new PropertyPath(MarginProperty));storyboard.Children.Add(animation);if (isChecked){Resources.Remove(Left);Resources[Right] storyboard;}else{Resources.Remove(Right);Resources[Left] storyboard;}storyboard.Begin();}}}3、开关界面与主窗体菜单实现 1、开关界面实现 ToggleButtonWindow.xaml 代码如下所示: Window x:ClassWpf_Examples.Views.ToggleButtonWindowxmlnshttp://schemas.microsoft.com/winfx/2006/xaml/presentationxmlns:xhttp://schemas.microsoft.com/winfx/2006/xamlxmlns:dhttp://schemas.microsoft.com/expression/blend/2008xmlns:mchttp://schemas.openxmlformats.org/markup-compatibility/2006xmlns:ccclr-namespace:CustomControlLib;assemblyCustomControlLibxmlns:localclr-namespace:Wpf_Examples.Viewsmc:IgnorabledTitleToggleButtonWindow Height450 Width800 Background#2B2B2BWindow.ResourcesStyle x:KeyToggleSwitchStyleChangeAnimate TargetTypeCheckBoxSetter PropertyTemplateSetter.ValueControlTemplate TargetTypeCheckBoxStackPanel OrientationHorizontalGridBorder CornerRadius22 Width80 Height44 BackgroundLightGray/Border CornerRadius18 x:Namebutton Width36 Height36 HorizontalAlignmentLeft//Grid/StackPanelControlTemplate.ResourcesStoryboard x:KeytoLeftStoryboardThicknessAnimation Storyboard.TargetPropertyMargin Storyboard.TargetNamebutton From40,0,0,0 To4,0,0,0 Duration0:0:0:0.3!--增加缓动处理让切换效果更加平滑--ThicknessAnimation.EasingFunctionCubicEase EasingModeEaseInOut//ThicknessAnimation.EasingFunction/ThicknessAnimation/StoryboardStoryboard x:KeytoRightStoryboardThicknessAnimation Storyboard.TargetPropertyMargin Storyboard.TargetNamebutton From4,0,0,0 To40,0,0,0 Duration0:0:0:0.3!--增加缓动处理让切换效果更加平滑--ThicknessAnimation.EasingFunctionCubicEase EasingModeEaseInOut//ThicknessAnimation.EasingFunction/ThicknessAnimation/Storyboard/ControlTemplate.ResourcesControlTemplate.TriggersTrigger PropertyIsChecked ValueFalseTrigger.EnterActionsRemoveStoryboard BeginStoryboardNameright/BeginStoryboard Storyboard{StaticResource toLeftStoryboard} x:Nameleft//Trigger.EnterActionsSetter TargetNamebutton PropertyBackground Value#737373//TriggerTrigger PropertyIsChecked ValueTrueTrigger.EnterActionsRemoveStoryboard BeginStoryboardNameleft/BeginStoryboard Storyboard{StaticResource toRightStoryboard} x:Nameright//Trigger.EnterActionsSetter TargetNamebutton PropertyBackground Value#25DC2D//Trigger/ControlTemplate.Triggers/ControlTemplate/Setter.Value/Setter/Style/Window.ResourcesGrid HorizontalAlignmentCenterStackPanel OrientationVerticalCheckBox Style{StaticResource ToggleSwitchStyleChangeAnimate} Margin0 20 0 20/cc:ToggleSwitch Width80 Height44 Foreground#3CC330 Margin0 20 0 20/cc:ToggleSwitch Width100 Height60 Foreground#E72114//StackPanel/Grid /Window 上面我保留了原来的样式然后也使用了封装控件的方式来展示相同效果。自定义控件可以通过改变属性设置轻松实现不同按钮大小和选中颜色的设置而模板样式只能实现一种效果。 2、主窗体菜单实现 MainWindow.xaml 菜单中添加新的按钮代码如下 GridWrapPanelButton Width100 Height30 FontSize18 Content开关按钮 Command{Binding ButtonClickCmd} CommandParameter{Binding RelativeSource{RelativeSource ModeSelf},PathContent} Margin8//WrapPanel/GridMainViewModel.cs 的菜单功能按钮添加新的页面弹窗代码如下 case 开关按钮:PopWindow(new ToggleButtonWindow());break;4、源代码获取 CSDN 资源下载链接自定义开关控件封装实现
http://www.w-s-a.com/news/194983/

相关文章:

  • 河南省建设科技网站浅谈电子商务网站建设与规划
  • 网站空间需要续费青海网站建设推广
  • 网站开发本地环境企业网站建设排名口碑
  • 做新闻的网站怎样赚钱个人网站课程设计报告
  • 网站设计样例那个网站做图片好看
  • 小型公司网站建设深圳网络营销策划有限公司
  • 国内优秀企业网站做视频网站用什么系统
  • 网站建设入门pdfwordpress网站标题
  • 专业网站的定义网站运营的概念
  • 外贸服装网站建设网页美工设计说明书
  • 郑州专业做网站公百度翻译api wordpress
  • 做网站哪里找大学的一级或二级域名
  • 没有静态ip可以做网站服务器上饶网站制作需要多少钱
  • 网站建设wangzhii做国外网站做什么内容
  • 网站建设 搞笑笑话经典 wordpress主题下载
  • 做网站要懂哪些wordpress 站点网络
  • 郑州外贸网站建设公司排名网站设计做啥好
  • 网站开发合同付款比例wordpress调用指定文章内容
  • 湖北平台网站建设哪里好辽宁建设工程信息网官网平台
  • 公司优化是什么意思?洛阳seo博客
  • 普通建站网站首页制作模板
  • 江苏城乡与住房建设厅网站wordpress 添加导航
  • 免费单页网站在线制作网站制作与网站建设pdf
  • 网站开发使用云数据库技术教程大连模板开发建站
  • 佘山网站建设创造网站需要多少钱
  • 南海佛山网站建设网站维护需要什么技能
  • 阿里云服务器开源做几个网站想找公司做网站
  • 一般做网站是用什么语言开发的域名查询 查询网
  • 地方门户网站源码下载揭阳专业网站建设
  • 网站做优化好还是推广好wordpress百家号模版