Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Wrap text so that it doesn't enlarge its panel

$
0
0

I need a Grid that auto-sizes to its content. There is also a caption text that should wrap so that it fits in that determined space. If the text is longer, it must not make the grid wider but instead wrap to multiple lines. Here's what I've tried, but it doesn't work.

<Page
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"><Grid Background="#ffff80" HorizontalAlignment="Left" VerticalAlignment="Top"><Grid.RowDefinitions><RowDefinition Height="Auto"/><RowDefinition Height="Auto"/></Grid.RowDefinitions><Grid.ColumnDefinitions><ColumnDefinition Width="Auto"/><ColumnDefinition Width="Auto"/></Grid.ColumnDefinitions><TextBlock Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" TextWrapping="Wrap" Text="1234567890 1234567890 1234567890"/><TextBlock Grid.Row="1" Grid.Column="0" Text="ABC"/><TextBlock Grid.Row="1" Grid.Column="1" Text="DEF"/></Grid></Page>

You can try it out in Kaxaml.


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>