In coding a WPF application I used a ListView and defined an template as a resource at that level:
<ListView IsSynchronizedWithCurrentItem="true" ItemTemplate="{StaticResource CardViewTemplate}">
<!--ItemTemplate="{StaticResource CardViewTemplate}" -->
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel></WrapPanel>
</ItemsPanelTemplate>
</ListView.ItemsPanel>
<ListView.Resources>
<DataTemplate x:Key="CardViewTemplate">
<GroupBox Header="{Binding Path=Product Name}" Width="290" BorderThickness="4" FontSize="14"
FontStyle="Normal" Padding="10" BorderBrush="DarkBlue" Background="{x:Null}" Margin="12"
UseLayoutRounding="True">
<StackPanel Name="stackPanel1">
<WrapPanel Orientation="Vertical" Name="wrapPanel1">
<WrapPanel Orientation="Horizontal">
<TextBlock MinWidth="80" Text="{Binding Path=Product
Name}" FontSize="16" FontWeight="Bold"
TextAlignment="Center" />
</WrapPanel>
</GroupBox>
</DataTemplate>
</ListView.Resources>
</ListView>
This works perfectly however when I use a Resource (Expression Dark) at the Window Level the ListView appears blank.
Any suggestions as to what could be the cause? I have tried everything I could think about
There could be multiple reasosns…
ListViewdirectly under yourWindow?Darktemplate correctly configured?Does it apply if you directly set it under the list view (without static resource reference)…
?