首页 > 其他 > 详细

模板绑定

时间:2016-04-27 18:44:59      阅读:299      评论:0      收藏:0      [点我收藏+]

模板绑定 : 通过使用模板绑定,模板可以从应用模板的控件中提取一个值。

<Window x:Class="TemplateDemo.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<ControlTemplate x:Key="ButtonTemplate" TargetType="{x:Type Button}">
<Border BorderBrush="#696A6B" BorderThickness="1" Background="Gray" TextBlock.Foreground="White">
<ContentPresenter RecognizesAccessKey="True" Margin="{TemplateBinding Padding}"></ContentPresenter>
</Border>
</ControlTemplate>
</Window.Resources>
<StackPanel>
<Button Margin="10" Padding="5" Template="{StaticResource ButtonTemplate}">
A Simple Button with a Custom Template
</Button>
</StackPanel>
</Window>

模板绑定

原文:http://www.cnblogs.com/gylhaut/p/5439796.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!