时间:2015年07月24日 | 作者 : aaronyang | 分类 : vs2015 | 浏览: 4595次 | 评论 1 人
======================================== AYUI www.ayjs.net AY 杨洋原创编写,请不要转载谢谢===============
1.在xaml中,你可以用块的方式查看xaml,不必需要再到上方去修改样式等
2. 后台事件触发,xaml中修改
3. 原来blend的中实时预览中控件右击可以编辑模板,现在在vs2015的xaml设计器中也可以了,如果你应用的样式在外部资源文件,vs2015的xaml中会已块状显示区域让你编辑。
我们首先新建一个AyYellowButtonSytle.xaml的资源字典,
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:AYUI_360"> <Style x:Key="YellowButtonStyle" TargetType="{x:Type Button}"> <Setter Property="Padding" Value="5"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type Button}"> <Border x:Name="button_border" Background="Yellow" BorderBrush="blue" BorderThickness="1"> <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/> </Border> <ControlTemplate.Triggers> <Trigger Property="IsPressed" Value="true"> <Setter Property="Background" TargetName="button_border" Value="#000000"/> <Setter Property="Foreground" Value="#FFFFFF"/> </Trigger> <Trigger Property="IsEnabled" Value="false"> <Setter Property="Foreground" Value="#ADADAD"/> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style> </ResourceDictionary>
然后再app.xaml中合并资源
<Application x:Class="AYUI_360.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:AYUI_360" StartupUri="MainWindow.xaml"> <Application.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="/AYUI_360;component/AyYellowButtonSytle.xaml"/> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </Application.Resources> </Application>
然后在MainWindow.xaml使用这个资源,以前vs,xaml中是不可以即时预览修改的
4. 在vs2015中xaml开发者中的region
这个在以前的vs中的 xaml时候是不可以添加region的,以前我也想为什么不可以添加region,现在vs2015终于可以了!
本文章,AY第一时间看外国视频,纯英语,没有字幕,自己翻译和录制完成,希望对大家有用! 希望大家对AY多多支持
======================================== AYUI www.ayjs.net AY 杨洋原创编写,请不要转载谢谢===============
抖音:wpfui 工作wpf
目前在合肥企迈科技公司上班,加我QQ私聊
2023年11月网站停运,将搬到CSDN上
AYUI8全源码 Github地址:前往获取
杨洋(AaronYang简称AY,安徽六安人)和AY交流
高中学历,2010年开始web开发,2015年1月17日开始学习WPF
声明:AYUI7个人与商用免费,源码可购买。部分DEMO不免费
查看捐赠AYUI7.X MVC教程 更新如下:
第一课 第二课 程序加密教程
已有1位网友发表了看法:
发表评论