Unfortunately, a regular TextBox does not allow auto-cut to match the parent, but DOES NOT autoresist when the text does not fit.
To solve this problem, you can use a custom TextBox that reports the desired (0, 0) size. This is an ugly hack, but it works.
In the .xaml.cs file:
public class TextBoxThatDoesntResizeWithText : TextBox { protected override Size MeasureOverride(Size constraint) { return new Size(0, 0); } }
Then in the .xaml file:
<Window x:Class="YourNamespace.YourWindow" ... xmlns:local="clr-namespace:YourNamespace"> ... <local:TextBoxThatDoesntResizeWithText Height="Auto" Text="{Binding Path=LyricsForDisplay}" MinHeight="50" MaxHeight="400" Visibility="Visible" VerticalScrollBarVisibility="Auto" IsReadOnly="True" AllowDrop="False" TextWrapping="WrapWithOverflow"> </local:TextBoxThatDoesntResizeWithText> ... </Window>
ajarov
source share