关于WPF Style 复用的问题

Posted on 2013-12-26 18:11  xiaomaogong  阅读(349)  评论(0)    收藏  举报
 <StackPanel.Resources>
            <Style x:Key="ControlBaseStyle" TargetType="{x:Type FrameworkElement}">
                <Setter Property="Margin" Value="55,0,0,0" />
            </Style>
            <Style TargetType="{x:Type TextBlock}" BasedOn="{StaticResource ControlBaseStyle}"/>
        </StackPanel.Resources>

以上代码能实现多种控件之间的Margin这种常用属性的复用

博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3