Jaima Joseph

Jaima Joseph

  • NA
  • 94
  • 107.8k

How to add style to dynamic stackpanel in windows store apps

Nov 4 2014 1:41 AM
Hi, I have developed a store app to show a list of items dynamically from my database in my store app page .It is showing data perfectly. Now I want to change its style, but I don't know how to do. I have searched the net a lot and tried ,
1)
 




 <Application.Resources>
<ResourceDictionary>
<Style TargetType="StackPanel" >
<Setter Property="Background" Value="Red"/>
</Style>
/ResourceDictionary>


</Application.Resources>
2)Also I tried to add the code in cs file where I am adding the dynamic control like..,
Spanel.Background.SetValue();
etc.

 
but nothing is working ,I don't know how to code or where to code....
the dynamically added code is, 

foreach (var inv in Inventlist)
{
GridViewItem InvGridview = new GridViewItem();
StackPanel Spanel = new StackPanel();
 
 
//Spanel.Children.Add(new TextBlock() {Text="{Binding Title}" Style="{StaticResource TitleTextStyle}" TextWrapping="NoWrap"});
//Spanel.Background.SetValue();
Spanel.Children.Add(new TextBlock() { Text = "SKU: " + inv.SKUName.ToString() });
Spanel.Children.Add(new TextBlock() { Text = "Location: " + inv.LocName.ToString() });
Spanel.Children.Add(new TextBlock() { Text = "InventoryId: " + inv.InventoryId.ToString() });
 
InvGridview.Content = Spanel;
InventGrid.Items.Add(InvGridview);
 
}
 
Please help..