我有这样的代码:
<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得到了扩展器的背景,但是这个应该是白色的,但是它不应该得到扩展器的背景,为什么会发生这种情况呢?
发布于 2017-10-30 09:52:35
ItemsPresenter本身没有任何颜色,它必须是可见的封面。在ItemsControl中,ItemsPresenter将显示ItemsPanel,并且可以为该面板设置不同的背景。或者为<ItemsPresenter />添加一个封面
<Border Background="Wheat">
<ItemsPresenter />
</Border>https://stackoverflow.com/questions/47011885
复制相似问题