Reputation: 43
In stackpanel, I want two textblocks in same row.
in the image, I want the date and time at the same row. what should I do?
Following is source code:
<StackPanel VerticalAlignment="Bottom" Background="{ThemeResource ListViewItemOverlayBackgroundThemeBrush}">
<TextBlock Text="{Binding Title}" Margin="15,0,15,0"/>
<TextBlock Text="2015/03/01" Margin="15,0,15,10" HorizontalAlignment="Left"/>
<TextBlock Text="1:42:31" Margin="15,0,15,10" HorizontalAlignment="Right"/>
</StackPanel>
Upvotes: 3
Views: 5038
Reputation: 633
The default Orientation of StackPanel is Vertical, hence the three TextBlocks appear one below the other. You should add another StackPanel with its Orientation set to Horizontal and put the bottom two TextBlocks inside it.
<StackPanel VerticalAlignment="Bottom" Background="{ThemeResource ListViewItemOverlayBackgroundThemeBrush}">
<TextBlock Text="Title" Margin="15,0,15,0"/>
<StackPanel Orientation="Horizontal">
<TextBlock Text="2015/03/01" Margin="15,0,15,10" HorizontalAlignment="Left"/>
<TextBlock Text="1:42:31" Margin="15,0,15,10" HorizontalAlignment="Right"/>
</StackPanel>
</StackPanel>
Updated:
<StackPanel VerticalAlignment="Bottom" Background="{ThemeResource ListViewItemOverlayBackgroundThemeBrush}">
<TextBlock Text="Title" Margin="15,0,15,0"/>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Text="2015/03/01" Grid.Column="0" Margin="15,0,15,10" HorizontalAlignment="Left"/>
<TextBlock Text="1:42:31" Grid.Column="1" Margin="15,0,0,10" HorizontalAlignment="Right"/>
</Grid>
</StackPanel>
Upvotes: 8