I have a textblock and an image inside a stackpanel like this:
<StackPanel Height="Auto" Name=stackPanel" Width="Auto" Orientation="Horizontal" >
<TextBlock Height="Auto" Name="textBlock" Width="Auto" TextWrapping="Wrap" MaxWidth="168" />
<Image Margin="10,10,0,0" Name="image" />
</StackPanel>
So the image is next to the textblock. If the text of textblock is to long, the text will be wrapped. Now I want the image to drop a row too, so the image stays next to the last word of the textblock.
My idea was to do this with an if-statement:
if (textblockBlock.ActualHeight > 35)
{
// change margin
}
But this doesn't work, as the actual height of the textblock (appearently) doesn't change when the text is wrapped...
Could someone help me out with this?
Check for text length, if length is greater than your specified value then change margin
if (textblock.Text.Length>40)
{
//change margin
}