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构件(组件)开发技术而构建的一个快速开发应用平台.用于帮助中小型软件企业建立一条适合市 ...
随机推荐
- Tomcat8及之后版本出现的The valid characters are defined in RFC 7230 and RFC 3986
升级tomcat8及更高版本带来的问题 由于使用get请求,链接中参数携带特殊字符,由于Tomcat的新版本中增加了一个新特性,就是严格按照 RFC 3986规范进行访问 解析,而 RFC 3986规 ...
- AngularJs压缩时须要注意的事项
因为AngularJS是通过控制器构造函数的參数名字来判断依赖服务名称的.所以假设你要压缩控制器的JS代码.它全部的參数也同一时候会被压缩,这时候依赖注入系统就不能正确的识别出服务了. 假如我们的Co ...
- Net程序调试
Net程序调试 前言 作为一个.net开发工程师,不管是在写桌面程序.服务程序或web程序,在开发阶段,我们必须非常熟悉vs的动态调试技能,当然web程序可能还需要调试前端的脚本或样式,这不在本文的讨 ...
- Erlang中的record与宏
http://www.cnblogs.com/me-sa/archive/2011/07/20/erlang0006.html 在Erlang中使用Tuple ,数据项的顺序\数量都是确定的,一旦数据 ...
- 使用jsp,tomcat实现用户登录注册留言的代码
以下jsp中,未使用样式表对网页进行排版和表单的验证(每个jsp的表单填写的时候应该进行空值与空格的验证,防止提交时出错) 所有错误,链接到error.jsp <%@ page language ...
- WPF 针对数据源某个属性进行排序
原文:WPF 针对数据源某个属性进行排序 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/wanlong360599336/article/detai ...
- 网络编程C#
C#网络程序设计(1)网络编程常识与C#常用特性 网络程序设计能够帮我们了解联网应用的底层通信原理! (1)网络编程常识: 1)什么是网络编程 只有主要实现进程(线程)相互通信和基本的 ...
- HDU 3605Escape(缩点+网络流之最大流)
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=3605 本来打算昨天写两道题的,结果这个题卡住了,最后才发现是最后的推断条件出错了,推断满流的条件应该是 ...
- switch语句中default用法详解
当年学C语言switch开关语句的时候,很多人会告诉你它是这么用的: switch(表达式){ case常量表达式1: 语句1;break; case常量表达式2: 语句2;break; - case ...
- WPF的逻辑树与视觉树(2)Visual容器
原文:WPF的逻辑树与视觉树(2)Visual容器 一.摘要 虽然我们平时几乎不会从该类派生,但要想了解视觉树就必须要了解Visual,Visual是一个基本抽象类,继承自DependencyOb ...