浙江省邮电工程建设有限公司 网站,卓朴战略营销咨询,如何下载别人的网站模板,权威发布红底图片文章目录 前言项目地址项目Nuget包搭建项目初始化项目架构App.xaml引入MateralDesign资源包 项目初步分析将标题栏去掉DockPanel初步布局 资源字典举例 结尾 前言
最近在找工作#xff0c;发现没有任何的WPF可以拿的出手的工作经验#xff0c;打算仿照网易云搭建一个WPF版本… 文章目录 前言项目地址项目Nuget包搭建项目初始化项目架构App.xaml引入MateralDesign资源包 项目初步分析将标题栏去掉DockPanel初步布局 资源字典举例 结尾 前言
最近在找工作发现没有任何的WPF可以拿的出手的工作经验打算仿照网易云搭建一个WPF版本的。
项目地址 WPF仿网易云 Gitee仓库 项目Nuget包搭建
不管有没有用先把Nuget装好 项目初始化
我项目初始化用过我们先简单的项目初始化一下知识点有点多。我使用的是Prism的BlankApp项目 WPF 零基础入门笔记1WPF静态页面布局样式触发器 WPF 零基础入门笔记2控件模板数据模版 WPF 零基础入门笔记3数据绑定详解 WPF Material Design UI框架部分常用控件简单使用 WPF Live Charts2 自学笔记 .NET SqlSuger 简单介绍超快开发数据库 WPF Prims框架详解 WPF CommunityToolkit.Mvvm .NET Core 依赖注入 Microsoft.Extensions.DependencyInjection 项目架构
Models:实体类Services:服务类Utils:工具类View:视图ViewModels:视图数据ViewStyles:视图样式App.xaml:项目入口 App.xaml引入MateralDesign资源包
prism:PrismApplication x:ClassBlankApp1.Appxmlnshttp://schemas.microsoft.com/winfx/2006/xaml/presentationxmlns:xhttp://schemas.microsoft.com/winfx/2006/xamlxmlns:localclr-namespace:BlankApp1xmlns:materialDesignhttp://materialdesigninxaml.net/winfx/xaml/themesxmlns:prismhttp://prismlibrary.com/Application.ResourcesResourceDictionary!--添加MD 资源包--ResourceDictionary.MergedDictionariesmaterialDesign:BundledTheme BaseThemeLightPrimaryColorPinkSecondaryColorLime /ResourceDictionary Sourcepack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml //ResourceDictionary.MergedDictionaries/ResourceDictionary/Application.Resources
/prism:PrismApplication
项目初步分析 这个适合使用DogPanel。
将标题栏去掉 WPF-隐藏窗体标题栏和边框 Window .......WindowStyleNoneAllowsTransparencyTrueDockPanel初步布局
Window x:ClassBlankApp1.Views.MainWindowxmlnshttp://schemas.microsoft.com/winfx/2006/xaml/presentationxmlns:xhttp://schemas.microsoft.com/winfx/2006/xamlxmlns:MDhttp://materialdesigninxaml.net/winfx/xaml/themesxmlns:prismhttp://prismlibrary.com/prism:ViewModelLocator.AutoWireViewModelTruexmlns:Viewsclr-namespace:BlankApp1.ViewsWindowStyleNoneAllowsTransparencyTrueTitle{Binding Title}Height600Width800Window.ResourcesStyle x:KeyContentBorderTargetTypeBorderSetter PropertyBorderBrushValueBlack /Setter PropertyBorderThicknessValue3 //Style/Window.ResourcesDockPanel LastChildFillTrueBorder DockPanel.DockBottomHeight70Style{StaticResource ContentBorder} /Border DockPanel.DockLeftWidth100Style{StaticResource ContentBorder} /Border DockPanel.DockTopHeight60Style{StaticResource ContentBorder} /Border Style{StaticResource ContentBorder}BackgroundPinkHeightauto //DockPanel
/Window 资源字典
我们写样式的时候有时候样式写的特别多这样就需要字典引入。这里不得不吐槽资源字典是没有代码提示的必须纯手打
!--窗口控件就是Windows.Resource--
UserControl.ResourcesResourceDictionaryResourceDictionary.MergedDictionariesResourceDictionary Source/项目名;component/文件完整路径//ResourceDictionary.MergedDictionaries/ResourceDictionary
/UserControl.Resources举例
比如我这个资源文件 引入代码 UserControl.ResourcesResourceDictionaryResourceDictionary.MergedDictionariesResourceDictionary Source/BlankApp1;component/ViewStyles/TitleStyle.xaml//ResourceDictionary.MergedDictionaries/ResourceDictionary/UserControl.Resources记得引入了之后要重新生成一下解决方案WPF需要重新编译才能识别。
结尾
今天不早了写完这篇博客已经23:30了明天有空再接着更新。