I'm successfully getting a 开发者_StackOverflowTextBox to resize with a parent Border height but I need the TextBox to actually be 50 pixels smaller in height than the parent Border.
Any ideas how to achieve this?
The code I'm using is
<Border VerticalAlignment="Stretch" HorizontalAlignment="Stretch" >
<TextBox x:Name="txtActivityNotes" HorizontalAlignment="Stretch" Height="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Border}}, Path=ActualHeight}" AcceptsReturn="True" VerticalContentAlignment="Top" TextWrapping="WrapWithOverflow" VerticalScrollBarVisibility="Auto" />
</Border>
Can't you just set a bottom margin of 50?
<TextBox Margin="0,0,0,50" />
I've tried following and it works. add following to text box in xaml:
------
VerticalAlignment="Stretch"
HorizontalAlignment="Stretch"
Height="{Binding RelativeSource={RelativeSource FindAncestor, *AncestorType*={x:Type *Grid*}}, Path=ActualHeight}"
------
Here, AncestorType is type of container containing the textBox. In my case it was 'Grid'. And also add margin like,
Margin="0,0,0,50"
to keep distance from border below.
============
oops sorry i posted on the same page.!
how about using a converter on the binding to minus 50 off the height
heres an example of using a converter
精彩评论