Search code examples
c#uwpxaml-designer

Designer view not showing Group headers


I have a problem with group header in the Visual Studio 2015 designer. The group header do show up in while running my Windows 10 UWP app.

I have the following XAML:

<RelativePanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    <ListView x:Name="TracksOverview"
              IsItemClickEnabled="True"
              ItemsSource="{Binding Source={StaticResource TracksOverviewSource}}"
              ItemTemplate="{StaticResource TrackOverview}"
              RelativePanel.AlignBottomWithPanel="True" 
              RelativePanel.AlignTopWithPanel="True"
              RelativePanel.AlignLeftWithPanel="True">
        <ListView.GroupStyle>
            <GroupStyle>
                <GroupStyle.HeaderTemplate>
                    <DataTemplate>
                        <TextBlock Text="1900-2000"
                                   Foreground="White" />
                    </DataTemplate>
                </GroupStyle.HeaderTemplate>
            </GroupStyle>
        </ListView.GroupStyle>
    </ListView>
</RelativePanel>

I've taken a screenshot of my designer and of my program.

screenshot

As you can see the header doesn't show up int the designer view (left) but does while running (right).

First I thought there is something wrong with my binding but, it doesn't even show the static text, it does reserve some space for it.

Thanks in advance, Rick


Solution

  • First of all, if it works as expected while running, I wouldn't worry about header not showing up in design mode. However, if you want to see your design-time values displayed, then you need to look into setting the design-time data context with d: prefixes (e.g., d:DataContext for relevant controls) and design-time attributes.

    During design time, the Designer displays whatever it can evaluate while leaving out the ones it can't (like the Header in your case), which means you need to supply design time values. As a counter-argument, do you really want to devote time to populating design-time values when you know it works with real data? Design-time display has its purpose such as showing as close a replica UI of a working system. If this is not the aim I wouldn't worry about it.