问题描述
在WPF MVVM应用程序中,存在一个ListBox,其各个ListBoxItems包含一个包含3列和2行的Grid。第0行第1列是绑定到字符串属性的TextBox。大多数情况下,TextBox的Wrap属性设置为"NoWrap"。通过
绑定到与ListBoxItem关联的对象中的属性。但是,当突出显示该行时, ListBoxItem模型中的属性将更改为"Wrap"。这有效,但结果是视觉上的不和谐,因为ListBoxItem
根本没有延迟地改变高度。更有吸引力的是,往返于Wrap的过渡是否能够平稳地增长和缩小高度。这可能吗?如果是这样,怎么样?
Richard Lewis Haggard
In a WPF MVVM application a ListBox exists whose individual ListBoxItems contains a Grid of 3 columns and 2 rows. Row 0 Col 1 is a TextBox that is bound to a string property. Most of the time the TextBox's Wrap attribute is set to "NoWrap" through binding to a property in the object that is associated ListBoxItem. However, when the row is highlighted then the property in the ListBoxItem model changes to "Wrap". This works but the result is visually jarring because the ListBoxItem changes height with no delay at all. What would be much more appealing is if the transition to and from Wrap were to smoothly grow and shrink in height. Is this possible? If so, how?
Richard Lewis Haggard
推荐答案
什么是顺利?我想如果你想改变TextBox的TextWrapping,只需将TextWrapping从NoWrap更改为Wrap。你说过,结果是视觉上的不和谐,因为ListBoxItem根本没有延迟地改变高度,但我认为这是不可避免的。
What is smoothly? I think if you want to change TextBox's TextWrapping, you just change TextWrapping from NoWrap to Wrap. You said that the result is visually jarring because the ListBoxItem changes height with no delay at all, but I think this is inevitable.
最好问候,
Cherry
这篇关于如何让TextBox从'NoWrap'高度平滑过渡到'Wrap'高度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!