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

专业开发网站的公司深圳海外推广

专业开发网站的公司,深圳海外推广,网站设计步骤详解,怎样建立自己的网站卖东西文章目录 前言专栏和Gitee仓库依赖属性实战#xff1a;缩小#xff0c;全屏#xff0c;关闭按钮依赖属性操作封装主窗口传递this本身给TitleView标题控件主要代码MainWindow.xmalMainWindow.cs依赖属性方法封装TitleView.csTitleViewModelTitleViewModel实现效果 前言 这次… 文章目录 前言专栏和Gitee仓库依赖属性实战缩小全屏关闭按钮依赖属性操作封装主窗口传递this本身给TitleView标题控件主要代码MainWindow.xmalMainWindow.cs依赖属性方法封装TitleView.csTitleViewModelTitleViewModel实现效果 前言 这次我们来讲解一下WPF 的组件化开发流程组件化开发是是可以极大降低我们页面开发难度降低代码耦合的方法。这让我们可以将任意WPF界面进行拆解。因为我写过Vue所以我会按照Vue的逻辑将WPF进行组件化开发。 专栏和Gitee仓库 WPF仿网易云 Gitee仓库 WPF仿网易云 CSDN博客专栏 依赖属性 WPF为了提高性能限制了Binding的使用。需要将属性提前注册为依赖属性或者附加属性才能解决使用Binding语法。原因是每个能binding的属性需要在内存中开辟存储空间。WPF默认不能Binding需要主动声明才可以。 这个就是为什么Elelctron,Fullter等内存开销那么大是因为他们的将可能没用的的内存空间也设置了。 博客园 痕迹g WPF依赖属性详解 B站 十月的寒流 WPF 中依赖属性及附加属性的概念及用法 B站 微软系列技术教程 WPF依赖属性详解 实战缩小全屏关闭按钮 这里我讲解一下Window和UserControl两者的区别。Window就是整个窗口UserControl就是控件。Window负责窗口的一些方法比如拖拽缩小放大。而我们是组件化开发我们就需要将主窗口的this传给子组件 依赖属性操作封装 这里先去看我这个总结的博客。 WPF 用户控件依赖属性赋值 主窗口传递this本身给TitleView标题控件 因为我们是View和ViewModel开发所有的View只有传递参数和暴露依赖属性的作用实际的业务是ViewModel去做的。 所以我们传递的方向是 #mermaid-svg-kBvVvOlA3lFUo3jf {font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}#mermaid-svg-kBvVvOlA3lFUo3jf .error-icon{fill:#552222;}#mermaid-svg-kBvVvOlA3lFUo3jf .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-kBvVvOlA3lFUo3jf .edge-thickness-normal{stroke-width:2px;}#mermaid-svg-kBvVvOlA3lFUo3jf .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-kBvVvOlA3lFUo3jf .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-kBvVvOlA3lFUo3jf .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-kBvVvOlA3lFUo3jf .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-kBvVvOlA3lFUo3jf .marker{fill:#333333;stroke:#333333;}#mermaid-svg-kBvVvOlA3lFUo3jf .marker.cross{stroke:#333333;}#mermaid-svg-kBvVvOlA3lFUo3jf svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-kBvVvOlA3lFUo3jf .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaid-svg-kBvVvOlA3lFUo3jf .cluster-label text{fill:#333;}#mermaid-svg-kBvVvOlA3lFUo3jf .cluster-label span{color:#333;}#mermaid-svg-kBvVvOlA3lFUo3jf .label text,#mermaid-svg-kBvVvOlA3lFUo3jf span{fill:#333;color:#333;}#mermaid-svg-kBvVvOlA3lFUo3jf .node rect,#mermaid-svg-kBvVvOlA3lFUo3jf .node circle,#mermaid-svg-kBvVvOlA3lFUo3jf .node ellipse,#mermaid-svg-kBvVvOlA3lFUo3jf .node polygon,#mermaid-svg-kBvVvOlA3lFUo3jf .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-kBvVvOlA3lFUo3jf .node .label{text-align:center;}#mermaid-svg-kBvVvOlA3lFUo3jf .node.clickable{cursor:pointer;}#mermaid-svg-kBvVvOlA3lFUo3jf .arrowheadPath{fill:#333333;}#mermaid-svg-kBvVvOlA3lFUo3jf .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-kBvVvOlA3lFUo3jf .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-kBvVvOlA3lFUo3jf .edgeLabel{background-color:#e8e8e8;text-align:center;}#mermaid-svg-kBvVvOlA3lFUo3jf .edgeLabel rect{opacity:0.5;background-color:#e8e8e8;fill:#e8e8e8;}#mermaid-svg-kBvVvOlA3lFUo3jf .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-kBvVvOlA3lFUo3jf .cluster text{fill:#333;}#mermaid-svg-kBvVvOlA3lFUo3jf .cluster span{color:#333;}#mermaid-svg-kBvVvOlA3lFUo3jf div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-kBvVvOlA3lFUo3jf :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} MainWindow MainWindowViewModel TitleView的MainWindow依赖属性 TitleViewModel的MainWindow 主要代码 MainWindow.xmal Window x:ClassBlankApp1.Views.MainWindow......!--需要主动设置名称不然会Binding错误--Window.DataContextViewModels:MainWindowViewModel x:NameMainWindowViewModel //Window.DataContextDockPanel LastChildFillTrue!--其它代码--Grid DockPanel.DockTopMouseLeftButtonDownGrid_MouseLeftButtonDownHeightauto!--手动指定DataContext--Views:TitleView MainWindow{Binding MainWindow, ElementNameMainWindowViewModel} //Grid/DockPanel /WindowMainWindow.cs public partial class MainWindow : Window{public MainWindowViewModel ViewModel { get; set; }public MainWindow(){InitializeComponent();//重定向ViewModelViewModel (MainWindowViewModel)DataContext;ViewModel.MainWindow this;}} 依赖属性方法封装 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows;namespace BlankApp1.Utils {public class MyWpfExtensionView where View : class{/// summary/// 简化依赖注入代码/// /summary/// typeparam nameView/typeparam/// typeparam nameValue/typeparam/// param namename/param/// param nameaction/param/// returns/returnspublic DependencyProperty DependencyPropertySetValue(string name, ActionView, Value action){var res DependencyProperty.Register(name, typeof(Value), typeof(View), new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault,new PropertyChangedCallback((item, res) {var model item as View;var value (Value)res.NewValue;if (model ! null){action(model, value);}else{throw new Exception(model value is null);}})));return res;}} } TitleView.cs namespace BlankApp1.Views {/// summary/// TitleView.xaml 的交互逻辑/// /summarypublic partial class TitleView : UserControl{//这个只是为了代码提示不涉及逻辑public MainWindow MainWindow { get; set; }//初始化依赖属性构造器public static readonly MyWpfExtensionTitleView MyWpfExtension new MyWpfExtensionTitleView();//这个是简化后的依赖属性public static readonly DependencyProperty MainWindowProperty MyWpfExtension.DependencyPropertySetMainWindow(MainWindow, (view, value) {//通过依赖属性来获取MainWindow的对象view.TitileViewModel.MainWindow value;});/// summary/// DataContext的数据/// /summarypublic TitileViewModel TitileViewModel { get; set; }public TitleView(){InitializeComponent();//拿到DataContext数据重定向TitileViewModel (TitileViewModel)DataContext;}} } TitleViewModel using BlankApp1.Models; using BlankApp1.Views; using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Net.Http.Headers; using System.Text; using System.Threading.Tasks; using System.Windows;namespace BlankApp1.ViewModels {public partial class TitileViewModel:ObservableObject{public RelayCommand CloseWindow { get; set; }public RelayCommand MaxOrNormalWindow { get; set; }public RelayCommand MiniWindow { get; set; }public MainWindow MainWindow { get; set; }public TitileViewModel() {//.......其它代码CloseWindow new RelayCommand(() {MainWindow.Close();Debug.WriteLine(关闭窗口);});MaxOrNormalWindow new RelayCommand(() {if(MainWindow.WindowState WindowState.Normal){MainWindow.WindowState WindowState.Maximized;MainWindow.MaxHeight SystemParameters.MaximizedPrimaryScreenHeight;MainWindow.MaxWidth SystemParameters.MaximizedPrimaryScreenWidth;}else{MainWindow.WindowState WindowState.Normal;}Debug.WriteLine(最大化或正常窗口);});MiniWindow new RelayCommand(() {MainWindow.WindowState WindowState.Minimized;Debug.WriteLine(缩小窗口);});}} } TitleViewModel 就是绑定按钮事件我就不放了 详细代码看我的Gitee仓库地址 WPF仿网易云 Gitee仓库 实现效果
http://wiki.neutronadmin.com/news/278124/

相关文章:

  • 如何做网站的伪静态页面网站代理备案步骤
  • 外贸英文网站深圳网站制作的公司深圳app开发
  • 建网站是自己做还是用CMS教育类app开发价格表
  • 邗江建设局网站资料下载成品网站包含后台么
  • php搭建网站软件教育网络平台建设
  • 网站的方案温州网站优化指导
  • 部门网站建设管理经验交流材料商丘云网广告有限公司
  • 酒店自建网站的功能wordpress导航两行
  • 网站建设公司信科网络成都网站商城建设
  • 两个男性做网站新的网站建设技术
  • 大理州建设局网站门户网wordpress手机端菜单被挤到第二行
  • 网站开发招聘实习哔哩哔哩网页版怎么回到旧版
  • 网站运营维护工作 基本内容包括百度网页设计教程
  • 网站 首页布局 seo怎么弄一个公众号
  • 昆明 网站建设二手网站开发
  • 怎么在网站标头做图标网站做接口到app 价格
  • 万寿路网站建设wordpress 目录权限
  • 有建设银行信用卡怎么登陆不了网站建站费用报价单
  • 家具flash网站模板下载旅游网站建设论文题目
  • 沈阳网站建设成创哈尔滨建工建设有限公司
  • win2008r做网站网站主体负责人不是法人
  • 信阳企业网站建设wordpress 文章待审核
  • 域名解析后网站怎么建设成都优化教育百度推广
  • 宏福建设工程有限公司网站达州网站制作
  • 个人网站设计流程图管理咨询公司名称参考
  • 网站设计说明书范文微信公众二次开发平台
  • c 网站建设教程视频教程网站建设平台有哪些
  • 集团网站建设网络公司带搜索网站建设视频教程
  • 上海人才招聘哪个网站好如何建个人网站
  • iis服务器网站301重定向怎么做网站建设的可行性报告