This problem occurs due to the inability to migrate my TextBlock. Basically, as an attempt at the last attempt, I set MaxWidth on my container grid columns. I was surprised to find that my shortcut and text box still do everything they want (bad kids, BAD) and are not limited to my grid column MaxWidth = "200".
What I'm really trying to do is let my TextBlock fill the available width and wrap if necessary. As long as all attempts to HorizontalAlignment = "Stretch" on all known parents in the universe fail, nothing works except setting explicit MaxWidth = "400" or any other number in the TextBlock. This is not good, because I need the TextBlock to fill the available width, not limited to some fixed number. Thanks!
<ItemsControl> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <StackPanel /> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> <ItemsControl.ItemTemplate> <DataTemplate> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition MaxWidth="200" SharedSizeGroup="A" /> <ColumnDefinition MaxWidth="200" SharedSizeGroup="B" /> </Grid.ColumnDefinitions> <Label VerticalAlignment="Top" Margin="0 5 0 0" Grid.Column="0" Style="{StaticResource LabelStyle}" Width="Auto" Content="{Binding Value.Summary}" /> <TextBlock Grid.Column="1" Margin="5,8,5,8" FontWeight="Normal" Background="AliceBlue" Foreground="Black" Text="{Binding Value.Description}" HorizontalAlignment="Stretch" TextWrapping="Wrap" Height="Auto" /> </Grid> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl>
layout wpf grid textwrapping
devth
source share