Add InfoElement.ClearButtonInvisibleByHidden
.
#1596
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
InfoElement.ClearButtonInvisibleByHidden="False" (default value)
InfoElement.ClearButtonInvisibleByHidden="True"
可能你会觉得这个属性似乎没太大的必要,为元素(在这个例子中是
hc:TextBox
)设置一个MinWidth
不就解决了边框大小变化的问题了?或者HorizontalAlignment
设为Stretch
。考虑下如果在多语言支持的程序环境下,不同语言的Placeholder
长度差异可能非常大,为每个语言单独设置不同的MinWidth
非常麻烦,粗暴地设置Stretch
可能会导致TextBox
变得非常宽。同时,除去Placeholder
以后留空一大片空白影响美观。另一个有必要的场景如下:
Window 没有显式设置宽和高,而依赖内容自动计算出实际所需,这里实际是依赖
hc:TextBox
的宽度,而hc:TextBox
则依赖于Placeholder
,把鼠标移到hc:TextBox
上面触发ClearButton
进行显示会导致窗口自动变宽以包含ClearButton
的宽度;鼠标移开时又会触发ClearButton
隐藏导致窗口变窄。更直观的效果就是鼠标滑过这个hc:TextBox
的时候,整个窗口宽度会快速地变宽再还原,非常影响观感。