A ListBoxItem that fills its parent
I'm developing a Windows Phone app.
I have the following XAML:
<!--ContentPanel -->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<ListBox x:Name="SinglesGameList" Margin="0">
<ListBoxItem Margin="10,10,10,5" Height="67" HorizontalAlignment="Center" VerticalAlignment="Center" Width="444">
<TextBlock Text="XXX"/>
</ListBoxItem>
</ListBox>
</Grid>
Instead of setting ListBoxItem Width="444" I'm wondering it there is another way to开发者_如何转开发 set it that fills its parent.
Any advice?
Can you try this?
<ListBox x:Name="yourListBox">
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch"></Setter>
</Style>
</ListBox.ItemContainerStyle>
</ListBox>
精彩评论