WPF之MahApps.Metro下载和WPF学习经验
这几天一直在学习WPF的东西。刚开始以为和Winform一样.拖拽控件来进行布局。结果远远没有那么简单。很多东西都需要自己写。包括样式。今天给大家分享一个 MahApps.Metro.
首先在NuGet程序包里搜索MahApps.Metro然后下载。当然说到这里。有些大家在搜索NuGET的时候等待时间过长,搜索不到之类的。以及一些有关方面的一个博客。我好多东西都是从他的博客总结。
链接:http://www.wxzzz.com/
当然我自己写个很逗比的东西,是才接触WPF做的。有兴趣的或者才开始学的可以看下。至于大神级别的希望可以指点下。
<controls:MetroWindow x:Class="WpfApplication1.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="测试按钮" Height="" Width="">
<controls:MetroWindow.RightWindowCommands>
<controls:WindowCommands>
<Button Content="settings" />
<Button Content="设置" />
</controls:WindowCommands>
</controls:MetroWindow.RightWindowCommands> <Grid>
<Rectangle Height="" Stroke="White" Fill="SkyBlue"></Rectangle>
<Button Content="点击逐渐增长" Height="" HorizontalAlignment="Left" Margin="29,37,0,0" Name="btnGrowAdd" VerticalAlignment="Top" Width="" Click="btnGrowAdd_Click" />
<Button Content="点击逐渐归位" Height="" HorizontalAlignment="Left" Margin="29,87,0,0" Name="btnBack" VerticalAlignment="Top" Width="" Click="btnBack_Click" /> <StackPanel Grid.Row="" Grid.Column="" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="20,0,0,0">
<Border Width="" Height="" RenderTransformOrigin="0.391,0.424">
<Border.Background>
<ImageBrush ImageSource="/images/绿色输入框.png"/>
</Border.Background>
<TextBox x:Name="Phone" Style="{DynamicResource InPutTextBox}" Width="" VerticalAlignment="Center" HorizontalAlignment="Center" Text="{Binding Phone}" Margin="38,21,9,20" Height=""/>
</Border>
</StackPanel>
<Button Height="" HorizontalAlignment="Left" Margin="99,207,0,0" Name="btnGrow" VerticalAlignment="Top" Width="" Click="btnGrow_Click" >
<Button.Template>
<ControlTemplate TargetType="{x:Type Button}">
<Border Name="ThisBorder" Cursor="Hand" CornerRadius="" BorderThickness="">
<Border.Background>
<ImageBrush ImageSource="/images/普通按钮.png"/>
</Border.Background>
<Border VerticalAlignment="Center" HorizontalAlignment="Center"> <Label FontFamily="微软雅黑" FontSize="" Foreground="White" Content="点击增长" VerticalAlignment="Bottom" HorizontalAlignment="Center"/> </Border>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsPressed" Value="True">
<Setter TargetName="ThisBorder" Property="Background">
<Setter.Value>
<ImageBrush ImageSource="/images/普通按钮按下.png"/>
</Setter.Value>
</Setter>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Button.Template> </Button> <Button Content="弹出" Height="" HorizontalAlignment="Left" Name="btndc" VerticalAlignment="Top" Width="" Click="btndc_Click" Margin="99,279,0,0">
<Button.Background>
<ImageBrush ImageSource="/images/普通按钮.png"/>
</Button.Background> </Button>
<Button Content="SS" Height="" HorizontalAlignment="Left" x:Name="btnss" VerticalAlignment="Top" Width="" Margin="223,278,0,0" Click="btnss_Click">
<Button.Background>
<ImageBrush ImageSource="images/普通按钮.png"/>
</Button.Background> </Button>
<Button Content="小球" Height="" HorizontalAlignment="Left" x:Name="xiuqiu" VerticalAlignment="Top" Width="" Margin="99,243,0,0" Click="xiuqiu_Click">
<Button.Background>
<ImageBrush ImageSource="images/普通按钮.png"/>
</Button.Background> </Button> </Grid>
</controls:MetroWindow>
这个是 wpf窗体的程序,这里面用过MahApps.Metro部分的。其中要把默认的Window 改为controls:MetroWindow。后台的 window 也改为MetroWindow
附上后台代码。只是为了测试几个按钮的效果。
public MainWindow()
{
InitializeComponent();
btnGrowAdd.Click += new RoutedEventHandler(btnGrowAdd_Click);
btnBack.Click += new RoutedEventHandler(btnBack_Click);
btnGrow.Click += new RoutedEventHandler(btnGrow_Click);
} //点击增长
private void btnGrow_Click(object sender, RoutedEventArgs e)
{
DoubleAnimation widthAnimation = new DoubleAnimation() { By = , Duration = TimeSpan.FromSeconds(0.2) };
btnGrow.BeginAnimation(Button.WidthProperty, widthAnimation);
Phone.Text += ;
} private void btnGrowAdd_Click(object sender, RoutedEventArgs e)
{
DoubleAnimation widthAnimation = new DoubleAnimation()
{
To = this.Width - ,
Duration = TimeSpan.FromSeconds()
};
DoubleAnimation heightAnimation = new DoubleAnimation()
{
To = (this.Height - ) / ,
Duration = TimeSpan.FromSeconds()
};
btnGrowAdd.BeginAnimation(Button.WidthProperty, widthAnimation);
btnGrowAdd.BeginAnimation(Button.HeightProperty, heightAnimation);
} private void btnBack_Click(object sender, RoutedEventArgs e)
{ DoubleAnimation widthAmination = new DoubleAnimation();
widthAmination.Duration = TimeSpan.FromSeconds();
DoubleAnimation heightAmimation = new DoubleAnimation();
heightAmimation.Duration = TimeSpan.FromSeconds();
btnGrow.BeginAnimation(Button.WidthProperty, widthAmination);
btnGrow.BeginAnimation(Button.HeightProperty, widthAmination);
btnGrowAdd.BeginAnimation(Button.WidthProperty, widthAmination);
btnGrowAdd.BeginAnimation(Button.HeightProperty, heightAmimation);
Phone.Text = "";
} private void btndc_Click(object sender, RoutedEventArgs e)
{
this.ShowMessageAsync("标题", "内容", MessageDialogStyle.Affirmative, new MetroDialogSettings() { AffirmativeButtonText = "确定" });
}
最后感谢大家花时间看。因为这是第一次写博客,希望大家多提意见。一起进步。。
WPF之MahApps.Metro下载和WPF学习经验的更多相关文章
- WPF 使用MahApps.Metro UI库
在WPF中要想使用Metro风格是很简单的,可以自己画嘛.. 但是为了节省时间,哈,今天给大家推荐一款国外Metro风格的控件库. 本文只起到抛砖引玉的作用,有兴趣还是推荐大家上官网,Thanks,官 ...
- WPF清爽酷炫的界面Mahapps.metro
最近WPF项目中要求软件的风格要传统化一点,查阅了下资料发现了Mahapps.metro. 官网 http://mahapps.com/ 下面是官方的DOME,https://github.com/M ...
- 关于WPF界面框架MahApps.Metro的一个BUG
碰到了这个问题,记录一下,以便以后查阅: 在一个WPF项目中使用MahApps.Metro界面框架,其中有一个功能是嵌入一个带句柄的标记. 首先WPF是出了窗体和WebBrowser带有句柄外,其他控 ...
- C# WPF开源控件库:MahApps.Metro
其实站长很久之前就知道这个开源WPF控件库了,只是一直欣赏不了这种风格,但也star了该项目.每次浏览该仓库时,发现star越来越多,也看到很多网友对它的褒奖,所以今天就向大家推荐这款WPF控件库. ...
- 在 WPF 中使用 MahApps.Metro.IconPacks 提供的大量图标
MahApps.Metro.IconPacks https://github.com/MahApps/MahApps.Metro.IconPacks 提供了大量的高质量的图标供WPF使用,极其方便. ...
- 使用WPF来创建 Metro UI程序
本文转载:http://www.cnblogs.com/TianFang/p/3184211.html 这个是我以前网上看到的一篇文章,原文地址是:Building a Metro UI with W ...
- AvalonDock 2.0+Caliburn.Micro+MahApps.Metro实现Metro风格插件式系统(一)
随着IOS7由之前UI的拟物化设计变为如今的扁平化设计,也许扁平化的时代要来了,当然我们是不是该吐槽一下,苹果什么时候也开始跟风了,自GOOGLE和微软界面扁平化过后,苹果也加入了这一队伍. Aval ...
- 开源插件 :MahApps.Metro.IconPacks
详见英文版:https://github.com/MahApps/MahApps.Metro.IconPacks/wiki 源代码名称:MahApps.Metro.IconPacks 源代码网址:ht ...
- AgileEAS.NET SOA 中间件平台5.2版本下载、配置学习(四):开源的Silverlight运行容器的编译、配置
一.前言 AgileEAS.NET SOA 中间件平台是一款基于基于敏捷并行开发思想和Microsoft .Net构件(组件)开发技术而构建的一个快速开发应用平台.用于帮助中小型软件企业建立一条适合市 ...
随机推荐
- 【codeforces 758A】Holiday Of Equality
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- 百度消息推送REST API探究
一.百度云推送介绍 云推送(Push)是百度开放云向开发者提供的消息推送服务:通过利用云端与客户端之间建立稳定.可靠的长连接来为开发者提供向客户端应用推送实时消息服务. 百度云推送服务支持推送三种类型 ...
- unresolved external symbol __forceAtlDllManifest错误的解决
作者:朱金灿 来源:http://blog.csdn.net/clever101 晚上编译一个ATL程序,出现一些诡异的错误: 1>CGreet.obj : error LNK2001: unr ...
- one hot 编码的实现
one hot 编码,针对的是类别性属性(categorical),类别型属性可以为特征向量中的任一属性,比如性别(one hot 编码的意义在于,属性之间不具有数值上大小的区别,在对最后结果的影响上 ...
- Erlang中频繁发送远程消息要注意的问题
http://avindev.iteye.com/blog/76373 注:这篇文章可能会有争议,欢迎提出意见 在Erlang中,如果要实现两个远程节点之间的通信,就需要通过网络来实现,对于消息发送, ...
- 理解Erlang/OTP - Application
http://www.cnblogs.com/me-sa/archive/2011/12/27/erlang0025.html 1>application:start(log4erl). 我们就 ...
- fastjson空对象不显示问题
今天在网上找了半天,看到一个大神自己搭建的网站,贴出了这个问题的解决办法,大家共享一下,对那些牛X的大神膜拜吧. 例子: Map < String , Object > jsonMap = ...
- boost::any在降低模块之间耦合性的应用
作者:朱金灿 来源:http://blog.csdn.net/clever101 在开发大型系统中,遵循这样一个原则:模块之间低耦合,模块内高内聚.比如系统中模块有界面模块和算法模块两种,一般是界面模 ...
- 无法写入预编译头文件,由于 IO 设备错误,无法运行此项请求的错误的解决
作者:朱金灿 来源:http://blog.csdn.net/clever101 早上查看服务器每日构建的情况,发现出现一个诡异的错误: fatal error C1085: 无法写入预编译头文件:& ...
- android studio报错提示: Gradle DSL method not found: 'android() 解决方案
原文错误提示: Error:(16, 0) Gradle DSL method not found: 'Android()'Possible causes:<ul><li>Th ...