wpf怎么使用第三方库

wpf怎么使用第三方库,第1张

For Example:引用MaterialDesign库(辅助界面设计的开源库)

Nuget:搜索MaterialDesign关键字,下载MaterialDesignThemes

在App.xaml 引入MD常用资源方便所有界面调用(不是所有第三方库都需要)

<Application x:Class="WpfApp2.App"

xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

xmlns:local="clr-namespace:WpfApp2"

StartupUri="MainWindow.xaml">

<Application.Resources>

<ResourceDictionary>

<ResourceDictionary.MergedDictionaries>

<!--MD-->

<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpfcomponent/Themes/MaterialDesignTheme.Light.xaml" />

<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpfcomponent/Themes/MaterialDesignTheme.Defaults.xaml" />

<ResourceDictionary Source="pack://application:,,,/MaterialDesignColorscomponent/Themes/Recommended/Primary/MaterialDesignColor.DeepPurple.xaml" />

<ResourceDictionary Source="pack://application:,,,/MaterialDesignColorscomponent/Themes/Recommended/Accent/MaterialDesignColor.Lime.xaml" />

</ResourceDictionary.MergedDictionaries>

</ResourceDictionary>

</Application.Resources>

</Application>

界面调用

先加载命名空间xmlns:md="http://materialdesigninxaml.net/winfx/xaml/themes"

使用

<Window x:Class="WpfApp2.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:WpfApp2"

xmlns:md="http://materialdesigninxaml.net/winfx/xaml/themes"

mc:Ignorable="d"

title="MainWindow" Height="450" Width="800">

<Grid>

<Button

Style="{StaticResource MaterialDesignFloatingActionMiniButton}"

HorizontalAlignment="Left"

ToolTip="MaterialDesignFloatingActionMiniButton">

<md:PackIcon

Kind="Alarm"

Height="20"

Width="20" />

</Button>

</Grid>

</Window>

WINFORM的控件可以直接在WPF中使用,放在WindowsFormsHost里面。

                                <WindowsFormsHost Grid.Row="1"

                                                  Background="Transparent">

                                    <winform:PropertyGrid x:Name="pgProperty"

                                                          PropertyValueChanged="pgProperty_PropertyValueChanged"

                                                          ToolbarVisible="False" />

                                </WindowsFormsHost>

WPF里的Frame控件自带导航栏,不过和你的有点差异,你可以试试。


欢迎分享,转载请注明来源:内存溢出

原文地址: http://www.outofmemory.cn/bake/11619651.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-17
下一篇 2023-05-17

发表评论

登录后才能评论

评论列表(0条)

保存