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

Incorrect floating hint position on outlined text box #2203

Closed
jizc opened this issue Jan 3, 2021 · 2 comments
Closed

Incorrect floating hint position on outlined text box #2203

jizc opened this issue Jan 3, 2021 · 2 comments
Labels
Milestone

Comments

@jizc
Copy link
Contributor

jizc commented Jan 3, 2021

After #2193, anytime an outlined text box is not the default height (like with multiline text, or when a fixed height is set), the floating hint is not positioned correctly.

This screenshot is from the Fields page in the demo app, where the text box Height is set to 100.
image

Here is a gif of the same text box where I have removed the fixed height. All I'm doing is adding blank lines:
outlined-text-box-issue

The issue seems to be due to the changes in FloatingHintOffsetCalculationConverter.

@Keboo Keboo added the bug label Jan 4, 2021
@MichelMichels
Copy link
Member

This is indeed a bug. But the problem isn't in the converter (but I also don't like the changes that were made to this converter, imo it's less readable now and there's more comments).

The problem resides in the MaterialDesignTheme.TextBox.xaml file. On line 241 and below you'll find following snippet:

<MultiBinding Converter="{StaticResource FloatingHintOffsetCalculationConverter}">
    <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="FontFamily" />
    <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="FontSize" />
    <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="(wpf:HintAssist.FloatingScale)" />
    <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="ActualHeight" />
</MultiBinding>

The problem lies in the last Binding in the MultiBinding. When changing the Path property to Padding, the bug is fixed. I don't think the ActualHeight is needed to calculate the offset of the hint.

@jizc
Copy link
Contributor Author

jizc commented Jan 23, 2021

Thank you for looking into it and submitting a PR 🎉

@Keboo Keboo added this to the 4.0.0 milestone Jan 24, 2021
@Keboo Keboo closed this as completed Jan 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants