关于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这种常用属性的复用

Copyright © 2024 xiaomaogong
Powered by .NET 9.0 on Kubernetes