I am creating a windows store application that currently loads a simple class (which loads 5 items).
I use a simple grid to load the items in and then set some styling;
code snippet;
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}" Margin="261,111,10,302">
<ListView ItemsSource="{Binding}" Name="lstMatters" SelectionMode="Multiple">
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Tapped="spMatter_Tapped" >
<Image Source="{StaticResource MatterImage}"></Image>
<GridView ItemContainerStyle="{StaticResource GridViewItemStyle1}" SelectionMode="None">
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel Orientation="Horizontal" IsHitTestVisible="False"/>
</ItemsPanelTemplate>
</GridView.ItemsPanel>
<GridViewItem Margin="3" Style="{StaticResource gridViewHeader}" Content="FileRef: " FontSize="20"></GridViewItem>
<GridViewItem Margin="3" Content="{Binding Path=FileRef}" FontSize="20"></GridViewItem>
<GridViewItem Margin="3" Style="{StaticResource gridViewHeader}" Content="Description: " FontSize="20"></GridViewItem>
<GridViewItem Margin="3" Content="{Binding Path=Description}" FontSize="20"></GridViewItem>
<GridViewItem Margin="3" Style="{StaticResource gridViewHeader}" Content="DocumentSet: " FontSize="20"></GridViewItem>
<GridViewItem Margin="3" Content="{Binding Path=DocumentSet}" FontSize="20"></GridViewItem>
<GridViewItem Margin="3" Style="{StaticResource gridViewHeader}" Content="MatterType: " FontSize="20"></GridViewItem>
<GridViewItem Margin="3" Content="{Binding Path=MatterType}" FontSize="20"></GridViewItem>
</GridView>
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ListView>
</Grid>
I am trying to create a “dynamic” style in the sence that, when the DocumentSet column loads and displays in the grid, the code will do a type of “switch” statement and according to the DocumentSet, use a spesific style.
(i.e. change the gridViewItem’s style depending on the DocumentSet’s value.
Switch DocumentSet
Case "a"
style = style.a
Case "b"
style = style.b)
Hope that made sense?
Thanks in advance.
Try this video by Jerry Nixon. It is basically to show how to implement interstitial ads, but you can use same concept by using the ListView.ItemTemplateSelector.
http://youtu.be/kTBdCgVVjug
Arun