首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ItemsPresenter从扩展器获取背景

ItemsPresenter从扩展器获取背景
EN

Stack Overflow用户
提问于 2017-10-30 09:33:02
回答 1查看 291关注 0票数 1

我有这样的代码:

代码语言:javascript
复制
<Expander IsExpanded="True" Background="#4F4F4F">
    <Expander.Header>
        <DockPanel Height="16.5">
            <TextBlock Text="{Binding Name}" FontWeight="Bold" Foreground="White" FontSize="11.5" VerticalAlignment="Bottom" />
            <TextBlock Text="{Binding ItemCount}" FontSize="11.5" Foreground="Orange" FontWeight="Bold" FontStyle="Italic" Margin="10,0,0,0" VerticalAlignment="Bottom" />
            <TextBlock FontSize="11.5" Foreground="White" FontStyle="Italic" FontWeight="Bold" VerticalAlignment="Bottom" >
                <TextBlock.Style>
                    <Style TargetType="{x:Type TextBlock}">
                        <Setter Property="Text" Value="sx"/>
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding ItemCount}" Value="1">
                                <Setter Property="Text" Value="s"/>
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </TextBlock.Style>
            </TextBlock>
        </DockPanel>
    </Expander.Header>
    <ItemsPresenter />
</Expander>

如您所见,我有一个扩展器,在扩展器中有一个ItemsPresenter。

膨胀机有一个黑色的背景,没有问题,但是问题是ItemsPresenter得到了扩展器的背景,但是这个应该是白色的,但是它不应该得到扩展器的背景,为什么会发生这种情况呢?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-10-30 09:52:35

ItemsPresenter本身没有任何颜色,它必须是可见的封面。在ItemsControl中,ItemsPresenter将显示ItemsPanel,并且可以为该面板设置不同的背景。或者为<ItemsPresenter />添加一个封面

代码语言:javascript
复制
<Border Background="Wheat">
    <ItemsPresenter />
</Border>
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47011885

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档