【问题标题】:Styling the content section of an Expander control为 Expander 控件的内容部分设置样式
【发布时间】:2010-12-10 15:58:14
【问题描述】:

如何将样式应用到 Expander 控件的内容部分?

【问题讨论】:

    标签: wpf styles expander


    【解决方案1】:

    想通了:

        <Style x:Key="ListItem" TargetType="{x:Type Expander}">
            <Setter Property="BorderBrush" Value="{StaticResource DefaultBorder}"/>
            <Setter Property="BorderThickness" Value="0,0,0,1"/>
            <Setter Property="Padding" Value="0,2"/>
    
            <Setter Property="ContentTemplate">
                <Setter.Value>
                    <DataTemplate>
                        <Border BorderBrush="{StaticResource DefaultBorder}" BorderThickness="0,1,0,0">
                            <Grid>
                                 <Border Background="Transparent" Padding="0,10,0,10" >
                                    <ContentControl Margin="24,0,0,0" Content="{TemplateBinding Content}"/>
                                </Border>
                            </Grid>
                        </Border>
                    </DataTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    

    我需要ContentControl。 :)

    【讨论】:

      【解决方案2】:

      由于扩展器的 Content 属性是 Object 类型,因此对 ContentControl 中可以放置的内容没有任何限制。您可以应用您想要的任何样式,具体取决于您想要显示的内容以及您希望如何显示它们。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2016-08-28
        • 2011-08-09
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多