How to refer MaxWidth=“??” of TextBlock to Owner ActualWidth?

不羁的心 提交于 2019-12-04 20:51:34

The problem with this is that StackPanels do not limit the size of their children, so will grow as much as their children need

Change your StackPanel to a control that limits the size of it's children, like a Grid (or wrap it in another control) and then use an ElementName binding to bind to the ActualWidth property of that control

<Grid Name="stpMessage" ... />
    ...
    <TextBlock MaxWidth="{Binding ElementName=stpMessage, Path=ActualWidth}" ... />
    ...
</Grid>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!