Kul Bhooshan

Kul Bhooshan

  • 1.7k
  • 28
  • 689

Add columns with textblock bind data dynamically in window10

Oct 6 2015 8:25 AM
I have a grid with 3 columns in list box item. There is a text block which bind with some json data. Based on data I want to show dynamic columns
with bind data. No of columns depend on story data. Here is my code.
<Grid x:Name="LayoutRoot" Background="{StaticResource ApplicationBackground1}" >
<Grid.RowDefinitions>
<RowDefinition Height="130"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<ScrollViewer x:Name="scrollViewer" Margin="130,0,0,0" Grid.Row="1" VerticalScrollBarVisibility="Disabled" ZoomMode="Disabled" VerticalScrollMode="Disabled" HorizontalScrollBarVisibility="Visible">
<Grid Background="White" Height="500" >
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="500" />
<ColumnDefinition Width="500" />
</Grid.ColumnDefinitions>
<Grid Grid.Column="0" Height="500" Width="400" Margin="10,5,10,-105" VerticalAlignment="Top">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0">
<StackPanel >
<TextBlock Text="{Binding Title}" FontSize="22" FontFamily="Georgia,Times New Roman,Times,serif" Margin="25,5,0,0" TextWrapping="WrapWholeWords" MaxLines="2" FontWeight="Normal" TextTrimming="WordEllipsis" />
</StackPanel>
<Image Source="{Binding Image}" Height="250" Width="380" Margin="20,10,10,10" Stretch="Fill" />
</StackPanel>
<TextBlock Text="{Binding Story}" FontSize="12" Margin="25,0,0,0" FontWeight="Light" Foreground="DimGray" Grid.Row="1" Style="{StaticResource BodyTextBlockStyle}" MaxLines="3" TextTrimming="WordEllipsis" />
</Grid>
<Grid Grid.Column="1" Margin="10,5,10,0" Background="White">
<ListBox x:Name="ItemsListBox" >
<ListBoxItem Margin="10" >
<TextBlock TextWrapping="Wrap" Text="{Binding Story}" FontSize="12" FontWeight="Light" />
</ListBoxItem>
</ListBox>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
</Grid>
</Grid>
</ScrollViewer>
 

Answers (3)