Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add InfoElement.ClearButtonInvisibleByHidden. #1596

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

GF-Huang
Copy link
Member

InfoElement.ClearButtonInvisibleByHidden="False" (default value)

JJXsCcpF95

InfoElement.ClearButtonInvisibleByHidden="True"

3IqkPCgOAS

可能你会觉得这个属性似乎没太大的必要,为元素(在这个例子中是 hc:TextBox)设置一个 MinWidth 不就解决了边框大小变化的问题了?或者 HorizontalAlignment 设为 Stretch。考虑下如果在多语言支持的程序环境下,不同语言的 Placeholder 长度差异可能非常大,为每个语言单独设置不同的 MinWidth 非常麻烦,粗暴地设置 Stretch 可能会导致 TextBox 变得非常宽。同时,除去 Placeholder 以后留空一大片空白影响美观。

另一个有必要的场景如下:

<Window ...
                 SizeToContent="WidthAndHeight">
  <StackPanel>
    ...
    <hc:TextBox ... hc:InfoElement.Placeholder="{MultiLangBinding xxx}"
                            hc:InfoElement.ShowClearButton="True" ... />
    ...
  </StackPanel>
</Window>

Window 没有显式设置宽和高,而依赖内容自动计算出实际所需,这里实际是依赖 hc:TextBox 的宽度,而 hc:TextBox 则依赖于 Placeholder,把鼠标移到 hc:TextBox 上面触发 ClearButton 进行显示会导致窗口自动变宽以包含 ClearButton 的宽度;鼠标移开时又会触发 ClearButton 隐藏导致窗口变窄。更直观的效果就是鼠标滑过这个 hc:TextBox 的时候,整个窗口宽度会快速地变宽再还原,非常影响观感。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant