标签:
模板绑定 : 通过使用模板绑定,模板可以从应用模板的控件中提取一个值。
<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