Mit*_*tch 3 wpf height textbox
我成功地使用父边框高度调整TextBox,但我需要TextBox实际上比父边框小50像素.
任何想法如何实现这一目标?
我正在使用的代码是
<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>
Run Code Online (Sandbox Code Playgroud)
小智 5
我试过跟随,它的工作原理。将以下内容添加到 xaml 的文本框中:
------
VerticalAlignment="Stretch"
HorizontalAlignment="Stretch"
Height="{Binding RelativeSource={RelativeSource FindAncestor, *AncestorType*={x:Type *Grid*}}, Path=ActualHeight}"
------
Run Code Online (Sandbox Code Playgroud)
这里,AncestorType 是包含文本框的容器类型。就我而言,它是“网格”。并添加保证金,例如,
Margin="0,0,0,50"
Run Code Online (Sandbox Code Playgroud)
与下方边界保持距离。
============
哎呀,对不起,我在同一页面上发布了。!