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

电商网站建设比较好的百度的网站域名

电商网站建设比较好的,百度的网站域名,网页设计素材,大连网站建设设计WPF 实现更换主题色WPF 使用 WPFDevelopers.Minimal 如何更换主题色作者#xff1a;WPFDevelopersOrg原文链接#xff1a; https://github.com/WPFDevelopersOrg/WPFDevelopers.Minimal框架使用大于等于.NET40#xff1b;Visual Studio 2022;项目使用 MIT 开源许可协议WPFDevelopersOrg原文链接    https://github.com/WPFDevelopersOrg/WPFDevelopers.Minimal框架使用大于等于.NET40Visual Studio 2022;项目使用 MIT 开源许可协议Nuget Install-Package WPFDevelopers.Minimal 3.2.6-preview定义一个公共颜色资源文件所有控件都动态资源引用DynamicResource颜色的Key然后这样修改一个资源文件的Key  SolidColorBrush的Color颜色值就可以实现更换主题色此篇主要是定义了多个公共颜色资源文件如下选择不同的资源文件进行更换App.xaml的资源字典实现更换主题色在Application.Current.Resources.MergedDictionaries.Remove(Blue) 字典寻找Blue然后移除在Application.Current.Resources.MergedDictionaries.Add(Green); 就完成更换主题色创建 Light.Blue创建 Light.Green创建 Light.Orange创建 Light.Pink创建 Light.Purple创建 Light.Purple使用 WPFDevelopers.Minimal 如何更换主题色Nuget包大于等于3.2.3如下新增主题色如下新建资源文件Light.Carmine.xaml如下自己更换颜色值即可ResourceDictionary xmlnshttp://schemas.microsoft.com/winfx/2006/xaml/presentationxmlns:xhttp://schemas.microsoft.com/winfx/2006/xamlxmlns:pohttp://schemas.microsoft.com/winfx/2006/xaml/presentation/options po:FreezeTrue!--Default颜色--Color x:KeyDefaultBorderBrushColor po:FreezeTrue#CD7474/ColorSolidColorBrush x:KeyDefaultBorderBrushSolidColorBrush Color{StaticResource DefaultBorderBrushColor} po:FreezeTrue/SolidColorBrushColor x:KeyDefaultBackgroundColor po:FreezeTrue#CFA0A0/ColorSolidColorBrush x:KeyDefaultBackgroundSolidColorBrush Color{StaticResource DefaultBackgroundColor} po:FreezeTrue/SolidColorBrushColor x:KeyDefaultBackgroundPressedColor po:FreezeTrue#B70404/ColorSolidColorBrush x:KeyDefaultBackgroundPressedSolidColorBrush Color{StaticResource DefaultBackgroundPressedColor} po:FreezeTrue/SolidColorBrush!--Primary颜色--Color x:KeyPrimaryNormalColor po:FreezeTrue#B31B1B/ColorSolidColorBrush x:KeyPrimaryNormalSolidColorBrush Color{StaticResource PrimaryNormalColor} po:FreezeTrue/SolidColorBrushSolidColorBrush x:KeyWindowBorderBrushSolidColorBrush Color{StaticResource PrimaryNormalColor} po:FreezeTrue/SolidColorBrushColor x:KeyPrimaryMouseOverColor po:FreezeTrue#BB5F5F/ColorSolidColorBrush x:KeyPrimaryMouseOverSolidColorBrush Color{StaticResource PrimaryMouseOverColor} po:FreezeTrue/SolidColorBrushColor x:KeyPrimaryPressedColor po:FreezeTrue#B70404/ColorSolidColorBrush x:KeyPrimaryPressedSolidColorBrush Color{StaticResource PrimaryPressedColor} po:FreezeTrue/SolidColorBrush/ResourceDictionary1把上面新增的资源添加App.xaml中即可Application x:ClassWPFDevelopers.Minimal.Sample.Appxmlnshttp://schemas.microsoft.com/winfx/2006/xaml/presentationxmlns:xhttp://schemas.microsoft.com/winfx/2006/xamlxmlns:wshttps://github.com/WPFDevelopersOrg.WPFDevelopers.MinimalStartupUriExampleViews\MainView.xaml ShutdownModeOnMainWindowCloseApplication.ResourcesResourceDictionaryResourceDictionary.MergedDictionariesResourceDictionary Sourcepack://application:,,,/WPFDevelopers.Minimal.Sample.Net40;component/Light.Carmine.xaml/!--需要注意ws:Resources 必须再配色主题后ThemeDark 为黑色皮肤 --ws:Resources ThemeLight/ResourceDictionary Sourcepack://application:,,,/WPFDevelopers.Minimal;component/Themes/Theme.xaml//ResourceDictionary.MergedDictionaries/ResourceDictionary/Application.Resources /Application2或者把资源添加到ThemesCollection集合中if (ThemesCollection ! null)ThemesCollection.Add(new ThemeModel{Color  #B31B1B,ResourcePath pack://application:,,,/WPFDevelopers.Minimal.Sample.Net40;component/Light.Carmine.xaml});重启应用效果如下1ThemeControl.cs代码如下using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Collections.Specialized; using System.ComponentModel; using System.Linq; using System.Windows; using System.Windows.Controls; using WPFDevelopers.Minimal.Helpers; using WPFDevelopers.Minimal.Models;namespace WPFDevelopers.Minimal.Controls {public class ThemeControl : Control{public static readonly DependencyProperty ItemsSourceProperty DependencyProperty.Register(ItemsSource, typeof(ObservableCollectionThemeModel), typeof(ThemeControl),new PropertyMetadata(null));static ThemeControl(){DefaultStyleKeyProperty.OverrideMetadata(typeof(ThemeControl),new FrameworkPropertyMetadata(typeof(ThemeControl)));}public ObservableCollectionThemeModel ItemsSource{get  (ObservableCollectionThemeModel)GetValue(ItemsSourceProperty);set  SetValue(ItemsSourceProperty, value);}public override void OnApplyTemplate(){base.OnApplyTemplate();ItemsSource  new ObservableCollectionThemeModel();ItemsSource.Add(new ThemeModel{Color  #409EFF,ResourcePath  pack://application:,,,/WPFDevelopers.Minimal;component/Themes/Light.Blue.xaml});ItemsSource.Add(new ThemeModel{Color  #FF033E,ResourcePath  pack://application:,,,/WPFDevelopers.Minimal;component/Themes/Light.Red.xaml});ItemsSource.Add(new ThemeModel{Color  #A21BFC,ResourcePath  pack://application:,,,/WPFDevelopers.Minimal;component/Themes/Light.Purple.xaml});ItemsSource.Add(new ThemeModel{Color  #FE9426,ResourcePath  pack://application:,,,/WPFDevelopers.Minimal;component/Themes/Light.Orange.xaml});ItemsSource.Add(new ThemeModel{Color  #00B050,ResourcePath  pack://application:,,,/WPFDevelopers.Minimal;component/Themes/Light.Green.xaml});ItemsSource.Add(new ThemeModel{Color  #FF007F,ResourcePath  pack://application:,,,/WPFDevelopers.Minimal;component/Themes/Light.Pink.xaml});if (ThemeCache.ThemesDictCache.Count  0)foreach (var item in ThemeCache.ThemesDictCache)if (ItemsSource.Any(x  x.Color ! item.Key))ItemsSource.Add(item.Value);SelectChecked();ItemsSource.CollectionChanged  ItemsSource_CollectionChanged;foreach (var theme in ItemsSource)theme.PropertyChanged  Theme_PropertyChanged;}private void SelectChecked(){var existsTheme  ItemsSource.FirstOrDefault(y Application.Current.Resources.MergedDictionaries.ToList().Exists(j j.Source ! null  y.ResourcePath.Contains(j.Source.AbsoluteUri)));if (existsTheme ! null)existsTheme.IsChecked  true;}private void ItemsSource_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e){switch (e.Action){case NotifyCollectionChangedAction.Add:foreach (ThemeModel item in e.NewItems){if (!ThemeCache.ThemesDictCache.ContainsKey(item.Color))ThemeCache.ThemesDictCache.Add(item.Color, item);item.PropertyChanged  Theme_PropertyChanged;SelectChecked();if (!item.IsChecked) return;ReviseTheme(item);}break;case NotifyCollectionChangedAction.Remove:foreach (ThemeModel item in e.NewItems)if (ThemeCache.ThemesDictCache.ContainsKey(item.Color))ThemeCache.ThemesDictCache.Remove(item.Color);break;case NotifyCollectionChangedAction.Replace:break;case NotifyCollectionChangedAction.Move:break;case NotifyCollectionChangedAction.Reset:break;}}private void Theme_PropertyChanged(object sender, PropertyChangedEventArgs e){if (e.PropertyName  nameof(ThemeModel.IsChecked)){var theme  sender as ThemeModel;if (!theme.IsChecked) return;ReviseTheme(theme);}}private void ReviseTheme(ThemeModel theme){if (theme  null) return;var old  ItemsSource.FirstOrDefault(x  x.IsChecked  x.Color ! theme.Color);if (old ! null){ItemsSource.Where(y  !y.Color.Equals(theme.Color)  y.IsChecked).ToList().ForEach(h  h.IsChecked  false);var existingResourceDictionary Application.Current.Resources.MergedDictionaries.FirstOrDefault(x x.Source ! null  x.Source.Equals(old.ResourcePath));if (existingResourceDictionary ! null)Application.Current.Resources.MergedDictionaries.Remove(existingResourceDictionary);var newResource Application.Current.Resources.MergedDictionaries.FirstOrDefault(x x.Source ! null  x.Source.Equals(theme.ResourcePath));if (newResource ! null) return;var newResourceDictionary  new ResourceDictionary { Source  new Uri(theme.ResourcePath) };Application.Current.Resources.MergedDictionaries.Insert(0, newResourceDictionary);ControlHelper.ThemeRefresh();}}}public class ThemeCache{public static Dictionarystring, ThemeModel ThemesDictCache  new Dictionarystring, ThemeModel();} }2Styles.ThemeControl.xaml代码如下ResourceDictionary xmlnshttp://schemas.microsoft.com/winfx/2006/xaml/presentationxmlns:xhttp://schemas.microsoft.com/winfx/2006/xamlxmlns:sysclr-namespace:System;assemblymscorlibxmlns:wpfscclr-namespace:WPFDevelopers.Minimal.Controlsxmlns:modelclr-namespace:WPFDevelopers.Minimal.ModelsResourceDictionary.MergedDictionariesResourceDictionary Source../Themes/Basic/ControlBasic.xaml/ResourceDictionary Source../Themes/Basic/Animations.xaml//ResourceDictionary.MergedDictionariesStyle TargetType{x:Type wpfsc:ThemeControl}Setter PropertyTemplateSetter.ValueControlTemplate TargetType{x:Type wpfsc:ThemeControl}ItemsControl ItemsSource{Binding ItemsSource,RelativeSource{RelativeSource AncestorTypewpfsc:ThemeControl}}ItemsControl.ItemTemplateDataTemplateRadioButton Height40 Width40 Margin4,0CursorHand IsChecked{Binding IsChecked}RadioButton.StyleStyle TargetType{x:Type RadioButton}Setter PropertyTemplateSetter.ValueControlTemplate TargetType{x:Type RadioButton}Border x:NamePART_BorderPadding2 BorderThickness0BorderBrush{Binding Color}Grid Background{x:Null}Rectangle x:NamePART_Rectangle Fill{Binding Color}/Path Data{StaticResource PathCheckMark}StretchFill Fill{DynamicResource BackgroundSolidColorBrush}VerticalAlignmentBottomHorizontalAlignmentRightHeight10 Width12Margin0,0,4,4Visibility{Binding IsChecked,Converter{StaticResource bool2VisibilityConverter}}//Grid/BorderControlTemplate.TriggersTrigger PropertyIsMouseOver ValueTrueSetter PropertyOpacity Value.8 TargetNamePART_Rectangle/Setter PropertyBorderThickness Value1 TargetNamePART_Border//TriggerTrigger PropertyIsChecked ValueTrueSetter PropertyBorderThickness Value1 TargetNamePART_Border//Trigger/ControlTemplate.Triggers/ControlTemplate/Setter.Value/Setter/Style/RadioButton.Style/RadioButton/DataTemplate/ItemsControl.ItemTemplateItemsControl.ItemsPanelItemsPanelTemplateWrapPanel//ItemsPanelTemplate/ItemsControl.ItemsPanel/ItemsControl/ControlTemplate/Setter.Value/Setter/Style /ResourceDictionary3ThemeControlExample.xaml代码如下!--命名空间--xmlns:wshttps://github.com/WPFDevelopersOrg.WPFDevelopers.MinimalTextBlock TextTheme FontSize20 Margin0,20,0,0/ws:ThemeControl Margin0,10 ItemsSource{Binding ThemesCollection,RelativeSource{RelativeSource AncestorTypelocal:MainView},ModeOneWayToSource}/ThemeControl|Github[1]ThemeControl|码云[2]Styles.ThemeControl.xaml|Github[3]Styles.ThemeControl.xaml|码云[4]参考资料[1] ThemeControl|Github: https://github.com/WPFDevelopersOrg/WPFDevelopers.Minimal/blob/main/src/WPFDevelopers.Minimal/WPFDevelopers.Minimal.Shared/Controls/ThemeControl.cs[2] ThemeControl|码云: https://gitee.com/WPFDevelopersOrg/WPFDevelopers.Minimal/blob/main/src/WPFDevelopers.Minimal/WPFDevelopers.Minimal.Shared/Controls/ThemeControl.cs[3] Styles.ThemeControl.xaml|Github: https://github.com/WPFDevelopersOrg/WPFDevelopers.Minimal/blob/main/src/WPFDevelopers.Minimal/WPFDevelopers.Minimal.Shared/Styles/Styles.ThemeControl.xaml[4] Styles.ThemeControl.xaml|码云: https://gitee.com/WPFDevelopersOrg/WPFDevelopers.Minimal/blob/main/src/WPFDevelopers.Minimal/WPFDevelopers.Minimal.Shared/Styles/Styles.ThemeControl.xaml
http://www.sadfv.cn/news/269023/

相关文章:

  • 三门峡市住房建设局网站给几个网址谢谢
  • 商贸城网站建设方案网站开发的投标案例
  • 睢县做网站网站建设实训分析总结
  • 冯耀宗seo视频教程网站优化的核心不包括
  • h5 和手机网站上海什么做网站的公司比较好
  • 玉树市wap网站建设公司汽车手机网站制作
  • wordpress 大网站wordpress可以商用吗
  • 怎么用域名建网站深圳网站建设外包公司哪家好
  • 红花岗区建设局网站建设银行成都市第九支行 网站
  • 怎么做网站注册推广网站的页面大小
  • 关键词搜索引擎工具怎么样优化关键词排名
  • 个人网站源码php太原新媒体运营公司
  • wordpress邀请码注册江苏seo团队
  • 网站制作流程论文wordpress搬家文章
  • 广东建设部网站海南省住建设厅网站报监
  • 网站投放广告怎么做用discuz做门户网站
  • 一个ip可以做几个网站互联网公司市值
  • 做网站 没内容wap免费网站
  • 如何查看网站流量海淀区网站搭建
  • 做汽车的网站做网站小程序在哪点拉客户
  • 消防做ccc去那个网站wordpress图片外链好
  • 容桂网站制作价格制作网站最新工具
  • 微信公众号怎么做网站链接网络运营商怎么看
  • 专业做高校网站群管理系统三网合一 营销型网站
  • 手机做网站内蒙和城乡建设部网站
  • 静态网站建设教程西安汇友网站建设
  • 二级域名可以做淘客网站网站开发适合女生吗
  • 小欢喜林磊儿什么网站做家教福州专业网站开发很专业
  • 建网站代理哪个怎么下载在线视频
  • 举例描述该如何布局网站关键词做淘宝客网站要注意什么