WPF界面美化(整体作用到控件),一步步教你使用FirstFloor.ModernUI

article/2025/10/12 21:43:31

开发工具:VS2015

1、获取相关DLL(通过NuGet或者GitHub上下载的源码中获得),并在项目中添加引用

FirstFloor.ModernUI.dll

Microsoft.Windows.Shell.dll

UIShell.OSGi(这个是我运行程序时报的错误"未能加载文件或程序集",然后在NuGet上下载得到的)

2、在.xaml文件中将MainWindow转为Mui.ModernUIWindow

.xaml.cs文件中继承Window改为继承ModernWindow

<mui:ModernWindow x:Class="GFunctionCalculate.MainWindow"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:d="http://schemas.microsoft.com/expression/blend/2008"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"xmlns:local="clr-namespace:GFunctionCalculate"xmlns:mui="http://firstfloorsoftware.com/ModernUI"mc:Ignorable="d"Title="MainWindow" Height="600" Width="800" WindowState="Normal" WindowStartupLocation="CenterScreen" ContentSource="/page1.xaml"><mui:ModernWindow.MenuLinkGroups><mui:LinkGroup DisplayName="" ><mui:LinkGroup.Links><mui:Link DisplayName="选择文件" Source="/page1.xaml"/><mui:Link DisplayName="数据列表" Source="/page2.xaml"/></mui:LinkGroup.Links></mui:LinkGroup></mui:ModernWindow.MenuLinkGroups>
</mui:ModernWindow>

 

using FirstFloor.ModernUI.Windows.Controls;
using FirstFloor.ModernUI.Presentation;namespace GFunctionCalculate
{/// <summary>/// MainWindow.xaml 的交互逻辑/// </summary>public partial class MainWindow : ModernWindow{public MainWindow(){InitializeComponent();}}
}

3、在App.xaml文件中添加样式(不添加运行会是全黑的窗口)

<Application x:Class="GFunctionCalculate.App"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:local="clr-namespace:GFunctionCalculate"StartupUri="MainWindow.xaml"><Application.Resources><ResourceDictionary><ResourceDictionary.MergedDictionaries><ResourceDictionary Source="/FirstFloor.ModernUI;component/Assets/ModernUI.xaml" /><ResourceDictionary Source="/FirstFloor.ModernUI;component/Assets/ModernUI.Light.xaml"/></ResourceDictionary.MergedDictionaries><Color x:Key="AccentColor">#008A00</Color><!--添加背景图片时使用--><!--<Rectangle x:Key="WindowBackgroundContent" x:Shared="false"><Rectangle.Fill><ImageBrush Opacity=".1" ImageSource="/Assets/background.Love.jpg" Stretch="UniformToFill" /></Rectangle.Fill></Rectangle>--></ResourceDictionary></Application.Resources>
</Application>

4、添加Page页

MainWindow中:

<mui:ModernWindow x:Class="GFunctionCalculate.MainWindow"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:d="http://schemas.microsoft.com/expression/blend/2008"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"xmlns:local="clr-namespace:GFunctionCalculate"xmlns:mui="http://firstfloorsoftware.com/ModernUI"mc:Ignorable="d"Title="MainWindow" Height="600" Width="800" WindowState="Normal" WindowStartupLocation="CenterScreen" ContentSource="/page1.xaml"><mui:ModernWindow.MenuLinkGroups><mui:LinkGroup DisplayName="" ><mui:LinkGroup.Links><mui:Link DisplayName="数据列表" Source="/page1.xaml"/></mui:LinkGroup.Links></mui:LinkGroup></mui:ModernWindow.MenuLinkGroups>
</mui:ModernWindow>

新建UserControl,命名为page1

page1.xaml

<UserControl x:Class="GFunctionCalculate.page1"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:GFunctionCalculate"xmlns:mui="http://firstfloorsoftware.com/ModernUI"xmlns:core="clr-namespace:System;assembly=mscorlib"mc:Ignorable="d" d:DesignHeight="600" d:DesignWidth="800"><Grid><Grid.Resources><!--Create list of enumeration values--><ObjectDataProvider x:Key="myEnum" MethodName="GetValues" ObjectType="{x:Type core:Enum}"><ObjectDataProvider.MethodParameters><x:Type Type="local:OrderStatus"/></ObjectDataProvider.MethodParameters></ObjectDataProvider></Grid.Resources><DockPanel><TextBlock DockPanel.Dock="Top" Text="DATAGRID" Style="{StaticResource Heading2}" Margin="0,0,0,8" /><DataGrid Name="DG1" ItemsSource="{Binding}" AutoGenerateColumns="False" ><DataGrid.Columns><mui:DataGridTextColumn Header="First Name"  Binding="{Binding FirstName}"/><mui:DataGridTextColumn Header="Last Name" Binding="{Binding LastName}" /><mui:DataGridTextColumn Header="Email" Binding="{Binding Email}"/><mui:DataGridCheckBoxColumn Header="Member" Binding="{Binding IsMember}" /><mui:DataGridComboBoxColumn Header="Order Status" SelectedItemBinding="{Binding Status}" ItemsSource="{Binding Source={StaticResource myEnum}}" /></DataGrid.Columns></DataGrid></DockPanel></Grid>
</UserControl>

page1.xaml.cs

using System.Collections.ObjectModel;
using System.Windows.Controls;namespace GFunctionCalculate
{public enum OrderStatus { None, New, Processing, Shipped, Received };public class Customer{public string FirstName { get; set; }public string LastName { get; set; }public string Email { get; set; }public bool IsMember { get; set; }public OrderStatus Status { get; set; }}/// <summary>/// Interaction logic for ControlsStylesDataGrid.xaml/// </summary>public partial class page1 : UserControl{public page1(){InitializeComponent();ObservableCollection<Customer> custdata = GetData();//Bind the DataGrid to the customer dataDG1.DataContext = custdata;}private ObservableCollection<Customer> GetData(){var customers = new ObservableCollection<Customer>();customers.Add(new Customer { FirstName = "Orlando", LastName = "Gee", Email = "orlando0@adventure-works.com", IsMember = true, Status = OrderStatus.New });customers.Add(new Customer { FirstName = "Keith", LastName = "Harris", Email = "keith0@adventure-works.com", IsMember = true, Status = OrderStatus.Received });customers.Add(new Customer { FirstName = "Donna", LastName = "Carreras", Email = "donna0@adventure-works.com", IsMember = false, Status = OrderStatus.None });customers.Add(new Customer { FirstName = "Janet", LastName = "Gates", Email = "janet0@adventure-works.com", IsMember = true, Status = OrderStatus.Shipped });customers.Add(new Customer { FirstName = "Lucy", LastName = "Harrington", Email = "lucy0@adventure-works.com", IsMember = false, Status = OrderStatus.New });customers.Add(new Customer { FirstName = "Rosmarie", LastName = "Carroll", Email = "rosmarie0@adventure-works.com", IsMember = true, Status = OrderStatus.Processing });customers.Add(new Customer { FirstName = "Dominic", LastName = "Gash", Email = "dominic0@adventure-works.com", IsMember = true, Status = OrderStatus.Received });customers.Add(new Customer { FirstName = "Kathleen", LastName = "Garza", Email = "kathleen0@adventure-works.com", IsMember = false, Status = OrderStatus.None });customers.Add(new Customer { FirstName = "Katherine", LastName = "Harding", Email = "katherine0@adventure-works.com", IsMember = true, Status = OrderStatus.Shipped });customers.Add(new Customer { FirstName = "Johnny", LastName = "Caprio", Email = "johnny0@adventure-works.com", IsMember = false, Status = OrderStatus.Processing });return customers;}}
}

 运行结果:

谢谢观看,有所帮助的话请点个赞"*★,°*:.☆( ̄▽ ̄)/$:*.°★* 。"

 


http://chatgpt.dhexx.cn/article/t4kKOJfD.shtml

相关文章

WPF 极简风格登录界面

UI使用MaterialDesign&#xff0c;先看界面 一、界面 极简登录界面 二、下载MaterialDesign包 我使用的是VS2019&#xff0c;选择要引入MaterialDesign包的项目&#xff0c;鼠标右击选择NuGet程勋包 在浏览页签中输入MaterialDesign&#xff0c;下载MaterialDesignColors和Ma…

WPF绘制自定义窗口

简介&#xff1a; 原文:WPF绘制自定义窗口 WPF是制作界面的一大利器&#xff0c;下面就用WPF模拟一下360的软件管理界面&#xff0c;360软件管理界面如下&#xff1a; 界面不难&#xff0c;主要有如下几个要素&#xff1a; 窗体的圆角 自定义标题栏及按钮 自定义状态栏 窗体的半…

WPF简单UI菜单设计

UI效果如下&#xff1a; XAML 设计&#xff1a; <Window x:Class"简单菜单设计.MainWindow"xmlns"http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x"http://schemas.microsoft.com/winfx/2006/xaml"xmlns:d"http://…

WPF真入门教程05--UI布局2

这一节&#xff0c;来学习下ComboBox下拉框&#xff0c;Border边框控件&#xff0c;Image图片控件&#xff0c;CheckBox复选框&#xff0c; 这些发挥着不同的作用&#xff0c;是布局基础组成部分&#xff0c;从左侧拖控件到右边&#xff0c;完成以下代码&#xff1a; <Wind…

WPF基本介绍

WPF基本介绍 WPF&#xff08;Windows Presentation Foundation&#xff09;是&#xff08;微软推出的&#xff09;基于Windows的用户界面框架&#xff0c;属于.NET Framework 3.0的一部分。WPF提供了统一的编程模型&#xff0c;语言和框架&#xff0c;做到了分离界面设计人员与…

WPF UI介面的革新

透過 Microsoft 對 Windows Vista 及 WPF 的強力行 銷&#xff0c;相信許多讀者對於WPF的UI能力只有驚豔二字可以形容&#xff0c;對於如何使用WPF來達到這些效果&#xff0c;基於雜誌與網路上已有相當多的文章討論&#xff0c;筆者於此就不再重述了&#xff0c;直接將主軸放在…

WPF界面设计—撸大师

WPF界面设计,模仿了金山卫士,360,鲁大师的界面! <!--无边框窗体--><Style x:Key="NoResize_window" TargetType="{x:Type Window}"> <Setter Property="AllowsTransparency" Value="true"/> <Setter Prope…

WPF - 简单的UI框架

实现了一个简单的WPF应用程序UI框架 &#xff0c;分享出来。界面效果图如下&#xff1a; 运行效果如下&#xff1a; 打算持续更新&#xff0c;将左侧面板所有功能模块全给实现了。 喜欢的可以下载源码体验&#xff1a;https://github.com/DuelWithSelf/WPFEffects 左侧分类导览…

WPF真入门教程04--UI布局1

大家都知道&#xff1a;UI是做好一个软件很重要的因素&#xff0c;如果没有一个漂亮的UI&#xff0c;功能做的再好也无法吸引很多用户使用&#xff0c;而且没有漂亮的界面&#xff0c;那么普通用户会感觉这个软件没有多少使用价值。 WPF系统基于流布局的标准&#xff0c;开发人…

WPF UI界面控件篇

WPF UI界面控件篇 布局控件&#xff1a;是任何用户界面的基础&#xff0c;排列应用中的 UI 元素。 文本、按钮和图像等元素都需要规定自己位置和行为方式&#xff0c;构建基块称为“控件”&#xff0c;有时亦称为“元素”。 <Window x:Class"UsingLayoutsApp.Wpf.Mai…

WPF(一) WPF基本控件与布局

​ WPF&#xff08;Windows Presentation Foundation&#xff09;是微软推出的基于Windows的用户界面框架&#xff0c;中文译为“Windows呈现基础”&#xff0c;属于.NET Framework 3.0的一部分。WPF类似于WinForm技术框架&#xff0c;但是相比于WinForm&#xff0c;WPF对大部分…

WPF炫酷界面设计

一.效果展示&#xff08;多层次&#xff09; 二.制作流程 1.在vs2012中建立一个wpf程序 2.建立一个主页面&#xff08;.cs&#xff09;(注&#xff1a;C#程序每一个页面都由两个文件构成一个axml一个cs&#xff0c;一个前端文件一个后台文件) 3.在主页面中添加按钮&#xff0c;…

WPF界面设计工具---Blend学习(一)

文章目录 前言一.初用Blend之喜二.使用Blend1.Blend工具版本 前言 最近在空闲时间学习WPF界面设计工具Blend&#xff0c;之前写WPF的界面都是完全依靠手敲代码的方式&#xff0c;这种方式往往很低效率而且很难做到一些复杂的效果。比如动画&#xff0c;手敲代码实现动画的话&a…

C# WPF 一个设计界面

微信公众号&#xff1a;Dotnet9&#xff0c;网站&#xff1a;Dotnet9&#xff0c;问题或建议&#xff1a;请网站留言&#xff0c; 如果对您有所帮助&#xff1a;欢迎赞赏。 C# WPF 一个设计界面 今天正月初三&#xff0c;大家在家呆着挺好&#xff0c;不要忘了自我充电。 武汉…

WPF界面设计

目录 1.设计一个优美的注册界面1.实现效果2.代码展示 2.简易登录按钮设计1.实现效果2.代码展示 3.设计一个优美的注册登录界面&#xff08;连接数据库&#xff09;1.实现效果2.代码展示 4.设计一个简单的在线教育系统界面1.实现效果2.代码展示 5. 设计一个Dashboard1.实现效果2…

WPF实例系列一:登录、注册界面设计

WPF实例系列一&#xff1a;登录、注册界面设计 文章目录 WPF实例系列一&#xff1a;登录、注册界面设计前言一、实例演示1. 登录界面展示2. 注册界面展示3. 数据存储4. 效果演示 二、结构及源码1.主界面跳转登录界面设计2.登录界面设计3.注册界面设计4.Excel保存数据类设计5.源…

C# WPF界面设计参考 工控机上位机界面 美观炫酷的现代化风格界面设计实际案例分享 界面设计代码

1.动图效果展示 2.界面1 3.界面2 4.界面3 需要界面效果代码的可留言联系博主

WPF界面设计学习

github上发现了一个不错的项目&#xff1a; https://github.com/HenJigg/wpf-uidesign 还配有B站的学习视频&#xff1a; https://space.bilibili.com/32497462 看了这个项目&#xff0c;觉得自己学了这么多年的WPF&#xff0c;界面还设计的这么丑&#xff0c;顿时脸都不知道往…

C# WPF十个美观的界面设计展示

概述 很多时候&#xff0c;我们设计的界面总是感觉缺乏美感&#xff0c;不是我们不会开发好看的界面&#xff0c;而是不知道怎么才算美观&#xff0c;这时候我们不妨看看别人好的页面是怎么做的.下面展示一些我觉得做的比较好的cs界面&#xff0c;希望能给大家在平时做界面设计…

WPF|分享一个登录界面设计

分享一个登录界面&#xff0c;先看效果图&#xff1a; 准备 文中使用到了一些图标&#xff1a; [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-ZsHcZCFv-1652400544809)(https://img1.dotnet9.com/2022/05/3402.png)] 我们可以从 iconfont免费下载…