wpf怎么使用第三方库

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了wpf怎么使用第三方库相关的知识,希望对你有一定的参考价值。

参考技术A 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.Wpf;component/Themes/MaterialDesignTheme.Light.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.DeepPurple.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/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>

qt 怎么使用第三方库

参考技术A 之前项目里使用其它的第三方库都是leader或同事给配置好的,从没操心这回事,真是惭愧,。今天同学给我发来一个工程,需用使用到Qt库和Qwt库,用QtCreator打开编译,提示找不到Qwt库里的头文件,于是试着配置一下,居然折腾了许久还没运行起来。后来看了一下Qt的qmake文档,才得以搞定。qmake 的说明文档里有关于声明使用其它库的说明:
Declaring Other Libraries
If you are using other libraries in your project in addition to those supplied with Qt, you need to specify them in your project file.
The paths that qmake searches for libraries and the specific libraries to link against can be added to the list of values in the LIBS variable. The paths to the libraries themselves can be given, or the familiar Unix-style notation for specifying libraries and paths can be used if preferred.
For example, the following lines show how a library can be specified:
[cpp] view plain copy
LIBS += -L/usr/local/lib -lmath
The paths containing header files can also be specified in a similar way using the INCLUDEPATH variable.
For example, it is possible to add several paths to be searched for header files:
[cpp] view plain copy
INCLUDEPATH = c:/msdev/include d:/stl/include
如果电脑上已经安装了Qt 和Qwt的环境,那么对于一个需要使用Qwt的程序来说,只需要在其工程文件中添加如下配置:
(假设你的Qwt安装目录为 C:/Qwt-6.0.1 )
1)在 LIBS 变量后面添加链接这个库的路径(例如-LC:/Qwt-6.0.1/lib)和名称(例如 -lqwt, 也可以用 qtAddLibrary(qwt) 添加动态库)
2)在INCLUDEPATH variable.后面添加这个引用该库所需要的头文件(例如 C:/Qwt-6.0.1/include)

[cpp] view plain copy
#include( $$PWD/../examples.pri )
#include( ../3rdparty/qwt/qwtplot.pri )
#include( C:/Qwt-6.0.1/features/qwtconfig.pri )
INCLUDEPATH += C:/Qwt-6.0.1/include #必须有
#DEPENDPATH += C:/Qwt-6.0.1/lib
#LIBS += -L/usr/local/lib -lmath
LIBS += -LC:/Qwt-6.0.1/lib -lqwt #必须有 否则报错 :-1: error: cannot find -lqwt
#qtAddLibrary(qwt) #必须有

#CONFIG += qwt本回答被提问者采纳

以上是关于wpf怎么使用第三方库的主要内容,如果未能解决你的问题,请参考以下文章

WPF工具开发: 第三库选择

materialdesigninxaml-WPF开源控件库

winform怎么遍历所有的第三方控件

WPF:WPF显示PDF文档

winform第三方控件Sidebar已添加进工具箱 怎么使用?怎么工具箱里没有控件

C# winform 怎么以管理员身份打开第三方APP