这几天一直在学习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学习经验的更多相关文章

  1. WPF 使用MahApps.Metro UI库

    在WPF中要想使用Metro风格是很简单的,可以自己画嘛.. 但是为了节省时间,哈,今天给大家推荐一款国外Metro风格的控件库. 本文只起到抛砖引玉的作用,有兴趣还是推荐大家上官网,Thanks,官 ...

  2. WPF清爽酷炫的界面Mahapps.metro

    最近WPF项目中要求软件的风格要传统化一点,查阅了下资料发现了Mahapps.metro. 官网 http://mahapps.com/ 下面是官方的DOME,https://github.com/M ...

  3. 关于WPF界面框架MahApps.Metro的一个BUG

    碰到了这个问题,记录一下,以便以后查阅: 在一个WPF项目中使用MahApps.Metro界面框架,其中有一个功能是嵌入一个带句柄的标记. 首先WPF是出了窗体和WebBrowser带有句柄外,其他控 ...

  4. C# WPF开源控件库:MahApps.Metro

    其实站长很久之前就知道这个开源WPF控件库了,只是一直欣赏不了这种风格,但也star了该项目.每次浏览该仓库时,发现star越来越多,也看到很多网友对它的褒奖,所以今天就向大家推荐这款WPF控件库. ...

  5. 在 WPF 中使用 MahApps.Metro.IconPacks 提供的大量图标

    MahApps.Metro.IconPacks https://github.com/MahApps/MahApps.Metro.IconPacks 提供了大量的高质量的图标供WPF使用,极其方便. ...

  6. 使用WPF来创建 Metro UI程序

    本文转载:http://www.cnblogs.com/TianFang/p/3184211.html 这个是我以前网上看到的一篇文章,原文地址是:Building a Metro UI with W ...

  7. AvalonDock 2.0+Caliburn.Micro+MahApps.Metro实现Metro风格插件式系统(一)

    随着IOS7由之前UI的拟物化设计变为如今的扁平化设计,也许扁平化的时代要来了,当然我们是不是该吐槽一下,苹果什么时候也开始跟风了,自GOOGLE和微软界面扁平化过后,苹果也加入了这一队伍. Aval ...

  8. 开源插件 :MahApps.Metro.IconPacks

    详见英文版:https://github.com/MahApps/MahApps.Metro.IconPacks/wiki 源代码名称:MahApps.Metro.IconPacks 源代码网址:ht ...

  9. AgileEAS.NET SOA 中间件平台5.2版本下载、配置学习(四):开源的Silverlight运行容器的编译、配置

    一.前言 AgileEAS.NET SOA 中间件平台是一款基于基于敏捷并行开发思想和Microsoft .Net构件(组件)开发技术而构建的一个快速开发应用平台.用于帮助中小型软件企业建立一条适合市 ...

随机推荐

  1. 【Linux】Linux下配置apache - 安装文件夹具体解释

    一,apache安装路径解释 默认安装路径   /var/apache2 # /etc/apache2/ # |-- apache2.conf # | `--  ports.conf # |-- mo ...

  2. mui常用功能链接地址

    1.下拉刷新mui.pullToRefresh插件http://ask.dcloud.net.cn/article/12152.打包app权限列表http://ask.dcloud.net.cn/ar ...

  3. springMVC返回json数据乱码问题及@RequestMapping 详解

    原文地址:https://blog.csdn.net/u010127245/article/details/51774074 一.@RequestMapping RequestMapping是一个用来 ...

  4. 开源server软件

    Java缓存server jmemcached http://www.oschina.net/p/jmemcached jmemcached 是一个Java版的 memcached 缓存server, ...

  5. PHP/HTML混写的四种方式总结

    PHP/HTML混写的四种方式总结 一.总结 一句话总结: 注意点: 1.双引号里面解析变量:echo "$Content" 2.HEREDOC和NOWDOC的关系:类似于双引号包 ...

  6. layer弹框在实际项目中的一些应用

    官方介绍:layer至今仍作为layui的代表作,受众广泛并非偶然,而是这五年多的坚持,不断完善和维护.不断建设和提升社区服务,使得猿们纷纷自发传播,乃至于成为今天的Layui最强劲的源动力.目前,l ...

  7. NotifyICon使用

    2010-04-11 15:47 by Ju2ender, 1438 visits, 网摘, 收藏, 编辑 最常见使用NotifyIcon的程序就是QQ了,当初我非常好奇这通知区域的小企鹅是怎样随着Q ...

  8. 【codeforces 785A】Anton and Polyhedrons

    [题目链接]:http://codeforces.com/contest/785 [题意] 给你各种形状的物体; 然后让你计算总的面数; [题解] 用map来记录各种物体本该有的面数; 读入各种物体; ...

  9. Green the world :使用monkey_patch

    eventlet的monkey_patch 用于绿化一些python的模块,看看以下的样例就明确了 urls = ["http://www.haha.mx/joke/1292935" ...

  10. 超级简单的9patch

    转载请声明出处:http://blog.csdn.net/dawanganban 我们在有些应用中会用到将图片内部指定区域撑大的效果,如微信中的消息内容背景,这时候就要用到9patch图片,效果如下: ...