日期:2014-05-17  浏览次数:20869 次

WPF,模板的属性设置问题
下面这个Button模板,来自MSDN的例子


 <Window.Resources>
        <Style TargetType="Button">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Button">
                        <Border Name="RootElement">
                            <Border.Background>
                                <SolidColorBrush x:Name="BorderBrush" Color="Black"/>
                            </Border.Background>
                            <Grid Margin="4" Background="{TemplateBinding Background}">
                                <ContentPresenter
                                    HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
                                    VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                    Margin="4,5,4,4" />
                            </Grid>
                        </Border>