当前位置: 首页 > 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://www.huolong8.cn/news/278124/

相关文章:

  • 大连市建设工程老网站百度快照和做网站有关系吗
  • 网站内页可以做关键词优化吗怎么开发一个直播app
  • 建设部网站投诉核查企业名单南通网站建设方案开发
  • 网站服务器搭建XP如何给网店做推广
  • 烟台市未成年思想道德建设网站婚纱摄影网页设计
  • 手机wap网站建站系统网站301重定向 权重转移
  • 松山湖网站建设合肥网络推广优惠设想科技
  • 网站开发公司的选择网络营销与推广的概念
  • 电商网站前端源码wordpress 出名主题
  • 网站优化提升速度制作网页一般用什么来设计分割页面
  • 行业网站做不下去网站建站哪家公司好一点
  • 凡科网站建设平台好么大型网站开发经典框架
  • 优秀的定制网站建设制作商展示类网站开发费用
  • 网站建设版面分几页合适网站开发一般用的什么架构
  • 重庆市建设项目环境影响评价网站软件下载网站排行榜前十名
  • 做电力公司网站玛酷机器人少儿编程加盟
  • dw做的网站如何让文字换行dedecms视频网站模板
  • 如何建立网站数据库连接公众号登录手机版
  • 建设标准 免费下载网站企业logo设计合同
  • 保定企业免费建站wordpress 语言选择器
  • 企业网站建设成本费用有和wind一样做用网站
  • 做知识产权相关的网站宁波网站建设兼职
  • 网站建设什么打王思聪网站返利二维码怎么做
  • 还有用asp做网站的吗网站开发蓝云
  • 做返利网站怎麼建设工程合同通用条款
  • 电商网站平台有哪些大学生对校园网站建设的需求是什么
  • 公司网站建设计划邵阳找工作网站
  • 聚美优品网站怎么做的网络科技有限公司起名
  • 做教育app的网站有哪些最新域名ip地址
  • 南昌网站制作建站模板平台