0

I have an UWP app (published in Windows/Microsoft Store), and I want add an Expander, based on the UWP Community Toolkit Sample App, but wanted to customize it. I have this code:

<controlsToolkit:Expander x:Name="Expander1"
                          Margin="0,0,0,10" 
                          Header="Details"
                          IsExpanded="False"
                          ExpandDirection="Down"
                          RelativePanel.AlignHorizontalCenterWithPanel="True"
                          RelativePanel.AlignVerticalCenterWithPanel="True"
                          Foreground="Gray"
                          BorderThickness="2">
    <controlsToolkit:Expander.BorderBrush>
        <SolidColorBrush Color="Gray" Opacity="0.4"/>
    </controlsToolkit:Expander.BorderBrush>
        <TextBlock HorizontalAlignment="Center"
                   TextWrapping="Wrap"
                   Text="Details Example"
                   VerticalAlignment="Center"/>
</controlsToolkit:Expander>

I want the expander button to have a gray border, but I do not know why that border does not appear:

enter image description here

And when I click on my expander, I want the background to be grayed out instead of this blue, but I do not know how I do it:

enter image description here

Fernando Sousa
  • 255
  • 2
  • 8

2 Answers2

2

Doesn't look like the Expander honors BorderBrush or BorderThicknes styles. I filed an issue and a PR to fix this.

The control will respect the Background property and will apply it to the Header and the Content. However, the ToggleButton used for the Header does have a style that applies a system color (the accent color) for when it is Checked (aka expanded).

You can modify the header color by adding a resource to the expander

<controls:Expander.Resources>
    <SolidColorBrush x:Key="SystemControlHighlightAccentBrush" Color="Red"/>
</controls:Expander.Resources>

Or you can restyle the control to change the ToggleButton style to not change the background color when it is checked

Shawn Kendrot
  • 12,425
  • 1
  • 25
  • 41
0

Have a look at the expander control template, add it to your page / app resources and tweak it. https://github.com/Microsoft/UWPCommunityToolkit/blob/master/Microsoft.Toolkit.Uwp.UI.Controls/Expander/Expander.xaml

I'll take a look at the issue you are facing soon.

Hermit Dave
  • 3,036
  • 1
  • 13
  • 13
  • I've been copying the code to the UWP Community Toolkit Sample App and based on that! And I just edited the code and customized it my way, which is what I want! I want to put a gray border around it and I can not! – Fernando Sousa Oct 31 '17 at 21:24
  • @shawn has filed an issue for this - https://github.com/Microsoft/UWPCommunityToolkit/issues/1583. could you by any chance create a repro ? – Hermit Dave Oct 31 '17 at 21:40