请与废柴的我谈恋爱10,uutxt.org,预告电影
您可以通过nuget gui(右键单击您的项目,单击manage nuget packages,选择online并搜索mahapps.metro)或使用package manager控制台安装mahapps.metro。
pm> install-package mahapps.metro
或使用软件包管理器控制台:
pm> install-package mahapps.metro -pre
您可以使用两种方法使用mahapps.metro设置window的样式:
安装mahapps.metro之后:
mainwindow.xaml
xmlns:controls="clr-namespace:mahapps.metro.controls;assembly=mahapps.metro"
xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
标签更改为
(请记住也要更改结束标签!)您应该有类似以下内容(请勿复制和粘贴):
<controls:metrowindow x:class="wpfapplication.mainwindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:controls="clr-namespace:mahapps.metro.controls;assembly=mahapps.metro" title="mainwindow" height="600" width="800"> <!-- your content --> </controls:metrowindow>
您还需要修改mainwindow.xaml.cs
文件,以使其基类mainwindow
与metrowindow
xaml文件的类匹配。
// to access metrowindow, add the following reference using mahapps.metro.controls; namespace wpfapplication { public partial class mainwindow : metrowindow { public mainwindow() { initializecomponent(); } } }
但是在大多数情况下,您可以删除基类(因为这是partial
xaml应该处理的类):
namespace wpfapplication { public partial class mainwindow { public mainwindow() { initializecomponent(); } } }
mahapp.metro的所有资源都包含在单独的资源词典中。为了使大多数控件采用mahapps.metro主题,您需要将resourcedictionaries添加到app.xaml
。
app.xaml(v2.0.0及更高版本)
<application x:class="wpfapplication.app" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" startupuri="mainwindow.xaml"> <application.resources> <resourcedictionary> <resourcedictionary.mergeddictionaries> <!-- mahapps.metro resource dictionaries. make sure that all file names are case sensitive! --> <resourcedictionary source="pack://application:,,,/mahapps.metro;component/styles/controls.xaml" /> <resourcedictionary source="pack://application:,,,/mahapps.metro;component/styles/fonts.xaml" /> <!-- accent and apptheme setting --> <resourcedictionary source="pack://application:,,,/mahapps.metro;component/styles/themes/light.blue.xaml" /> </resourcedictionary.mergeddictionaries> </resourcedictionary> </application.resources> </application>
app.xaml(v1.6.5和更低版本)
<application x:class="wpfapplication.app" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" startupuri="mainwindow.xaml"> <application.resources> <resourcedictionary> <resourcedictionary.mergeddictionaries> <!-- mahapps.metro resource dictionaries. make sure that all file names are case sensitive! --> <resourcedictionary source="pack://application:,,,/mahapps.metro;component/styles/controls.xaml" /> <resourcedictionary source="pack://application:,,,/mahapps.metro;component/styles/fonts.xaml" /> <resourcedictionary source="pack://application:,,,/mahapps.metro;component/styles/colors.xaml" /> <!-- accent and apptheme setting --> <resourcedictionary source="pack://application:,,,/mahapps.metro;component/styles/accents/blue.xaml" /> <resourcedictionary source="pack://application:,,,/mahapps.metro;component/styles/accents/baselight.xaml" /> </resourcedictionary.mergeddictionaries> </resourcedictionary> </application.resources> </application>
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
Blazor server side 自家的一些开源的, 实用型项目的进度之 CEF客户端
.NET IoC模式依赖反转(DIP)、控制反转(Ioc)、依赖注入(DI)
vue+.netcore可支持业务代码扩展的开发框架 VOL.Vue 2.0版本发布
网友评论