XAML 如何在WinUI 3中编辑Expander控件的标题?

kfgdxczn  于 2023-01-22  发布在  其他
关注(0)|答案(1)|浏览(127)

当我编辑Expander控件的属性时,效果似乎只应用于Expander的内容,而不是标头。
例如,如果我将BorderBrush设置为黑色,将Background设置为海蓝宝石,则这些属性仅适用于内容:

<Expander Header="Expander" BorderBrush="Black" Background="Aquamarine">
   <TextBlock Text="Here is some text"/>
</Expander>

See what the above code looks like
我知道我可以使用以下语法:

<Expander>
   <Expander.Header>
      <!--XAML content here-->
   </Expander.Header>
</Expander>

然后把XAML内容放到标头中,所以我试着把一个StackPanel放在那里,然后编辑它的边框和背景--但是它只应用于Expander标头的一小部分,并且没有覆盖下拉插入符号。
如何更改标头的属性?

wydwbb8l

wydwbb8l1#

您可以编辑默认样式,但这可能更简单:

<Border
    HorizontalAlignment="Left"
    VerticalAlignment="Center"
    Background="SkyBlue"
    BorderBrush="HotPink"
    BorderThickness="1"
    CornerRadius="{StaticResource ControlCornerRadius}">
    <Expander
        Content="CONTENT"
        Header="HEADER" />
</Border>

您只需要设置Border的属性。

相关问题