WPF - 集成HandyControl UI组件库
环境:net6 + wpf + HandyControl
一. 创建项目
二. 安装 NuGet 包
dotnet add package HandyControl
三. 引入 HandyControl 资源字典
在你的 WPF 项目中的 App.xaml
或主题文件中
1. 引入 HandyControl 资源字典。
2. 添加命名空间
<Application x:Class="BenchMarkMaster.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:BenchMarkMaster" xmlns:hc="https://handyorg.github.io/handycontrol" StartupUri="MainWindow.xaml"> <Application.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/SkinDefault.xaml"/> <ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/Theme.xaml"/> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </Application.Resources> </Application>
四. 页面代码
在MainWindow.xaml中添加命名空间
xmlns:controls="clr-namespace:HandyControl.Controls;assembly=HandyControl"
MainWindow.xaml代码:
<Window x:Class="laser.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:controls="clr-namespace:HandyControl.Controls;assembly=HandyControl" xmlns:local="clr-namespace:laser" mc:Ignorable="d" Title="主页" Height="450" Width="800"> <Grid> <VirtualizingStackPanel> <Button Content="这是一个按钮"/> <Button Content="连接" Width="60" Height="25" Margin="0 20 0 0" Background="#FF6BA731" Foreground="White" BorderBrush="#FFAFAEAE" BorderThickness="1" controls:BorderElement.CornerRadius="0"/> </VirtualizingStackPanel> </Grid> </Window>
引用:https://mp.weixin.qq.com/s?__biz=MzIxMTUzNzM5Ng==&mid=2247493994&idx=1&sn=afaa764eb31c01fc9260673c869cc5e6&scene=21#wechat_redirect
引用:https://github.com/handyOrg/HandyControl?tab=readme-ov-file
引用:https://blog.csdn.net/forcj/article/details/142253036
标签:HandyControl,xaml,UI,https,组件,WPF From: https://www.cnblogs.com/1285026182YUAN/p/18490052