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 missing templatebindings to NumberBox #2652

Merged
merged 1 commit into from
Jun 30, 2020

Conversation

marcelwgn
Copy link
Contributor

Description

This adds the TemplateBinding to NumberBox, that are necessary to customize FontSize, FontFamily and FontWeight.

Motivation and Context

Fixes #2603

How Has This Been Tested?

Tested manually:

image

Screenshots (if appropriate):

@msft-github-bot msft-github-bot added the needs-triage Issue needs to be triaged by the area owners label Jun 13, 2020
@mdtauk
Copy link
Contributor

mdtauk commented Jun 13, 2020

Things like this should have been caught before release.

I wonder if there shouldn't be some UI Test for customised control properties, to ensure the rendering matches the set properties?

@marcelwgn
Copy link
Contributor Author

Things like this should have been caught before release.
I wonder if there shouldn't be some UI Test for customised control properties, to ensure the rendering matches the set properties?

The problem is how to determine what the correct rendering is in every case. In this case, it was forgotten to test FontSize, which is unfortunate. At the end it was a bug, which shouldn't have happened, but well all bugs shouldn't happen.

Having a checklist for all the cases and options to check would be great and would help finding those bugs before they make it into production. Maybe this is something we should think about, however that list could potentially contain dozens or hundreds of checks, after all there are a lot of options to customize and use controls. Another option would be to test that automatically, however how do you determine what the correct rendering for all configurations is without a person deciding that at some point?

@mdtauk
Copy link
Contributor

mdtauk commented Jun 13, 2020

Things like this should have been caught before release.
I wonder if there shouldn't be some UI Test for customised control properties, to ensure the rendering matches the set properties?

The problem is how to determine what the correct rendering is in every case. In this case, it was forgotten to test FontSize, which is unfortunate. At the end it was a bug, which shouldn't have happened, but well all bugs shouldn't happen.

Having a checklist for all the cases and options to check would be great and would help finding those bugs before they make it into production. Maybe this is something we should think about, however that list could potentially contain dozens or hundreds of checks, after all there are a lot of options to customize and use controls. Another option would be to test that automatically, however how do you determine what the correct rendering for all configurations is without a person deciding that at some point?

Maybe that kind of thing should be decided at the spec stage?

Generally there is some common sense at play here. If the control has a FontSize property, changing the value should be reflected.

The default values in the ControlTemplates should reflect the 100% scaling Fluent Designs, but changing properties should override - this is what is expected.

Numberbox having sub controls, would need Template Bindings to the parent control in most cases, but I think some kind of Unit Test could be setup to test overriding of values on the parent control, and compare it to the render result.

@marcelwgn
Copy link
Contributor Author

Maybe that kind of thing should be decided at the spec stage?
Generally there is some common sense at play here. If the control has a FontSize property, changing the value should be reflected.

The problem is that a lot of properties are inherited from control, and are not part of the control itsself, that is that it was added specifically to the control. If you look at all the properties we inherit from the Control class, it might be very time expensive to think about all that are applicable for that control.

The default values in the ControlTemplates should reflect the 100% scaling Fluent Designs, but changing properties should override - this is what is expected.

Yes agreed, if there is any control that does not do that, I think that should change.

Numberbox having sub controls, would need Template Bindings to the parent control in most cases, but I think some kind of Unit Test could be setup to test overriding of values on the parent control, and compare it to the render result.

The problem is that, in order to verify all properties, we would need a lot of tests, and those tests can often break. We currently have VisualTreeVerification tests, however we do not have them for all controls (I think). I think this is an area we could improve on.

@mdtauk
Copy link
Contributor

mdtauk commented Jun 14, 2020

The problem is that a lot of properties are inherited from control, and are not part of the control itsself, that is that it was added specifically to the control. If you look at all the properties we inherit from the Control class, it might be very time expensive to think about all that are applicable for that control.

The problem is that, in order to verify all properties, we would need a lot of tests, and those tests can often break. We currently have VisualTreeVerification tests, however we do not have them for all controls (I think). I think this is an area we could improve on.

Not sure if this is a WinUI feature, or inherent with the language projections - but it would be a good idea to allow the hiding or removal of those Control properties that are not needed for the control inheriting from it.

Maybe there could be subsets of Control which can be categorised with certain properties?

I know its not a simple solution

@marcelwgn
Copy link
Contributor Author

marcelwgn commented Jun 14, 2020

Not sure if this is a WinUI feature, or inherent with the language projections - but it would be a good idea to allow the hiding or removal of those Control properties that are not needed for the control inheriting from it.

The issue here is that, that's how C++ and C# behave with inheritance.

Maybe there could be subsets of Control which can be categorised with certain properties?

The problem is that, in order to not inherit those properties, you would go up the chain of types so much that you are left with DependencyObject, since even UIObject has a lot of properties. However a lot of collection controls such as ListView or ItemsRepeater need some of those properties in order to work. So trying to not inherit from UIObject renders the control unusable in scenarios where it is being accessed/used by other controls.

I know its not a simple solution

Yes unfortunately, it's a very difficult problem, and there only seem to be options that always have some issues associated with them :/

@StephenLPeters
Copy link
Contributor

As @MikeHillberg said in the original issue, the text properties should flow down the visual tree to the children. Do we understand why these binding are needed here?

@@ -99,6 +99,8 @@
FontWeight="Normal"
Foreground="{ThemeResource TextControlHeaderForeground}"
Margin="{ThemeResource TextBoxTopHeaderMargin}"
FontSize="{TemplateBinding FontSize}"
FontFamily="{TemplateBinding FontFamily}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why isn't FontWeight needed here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have added "FontWeight=Normal", which I assumed was added for a reason (same why we enforce certain font sizes on other controls and their subcontrols).

@StephenLPeters
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@marcelwgn
Copy link
Contributor Author

As @MikeHillberg said in the original issue, the text properties should flow down the visual tree to the children. Do we understand why these binding are needed here?

No, I have no idea why those properties did not propagate down the visual tree.

@StephenLPeters StephenLPeters added area-NumberBox NumberBox Control team-Controls Issue for the Controls team and removed needs-triage Issue needs to be triaged by the area owners labels Jun 15, 2020
@robloo
Copy link
Contributor

robloo commented Jun 18, 2020

No, I have no idea why those properties did not propagate down the visual tree.

I wouldn't hide the bug without first understanding what's going on here. We need to understand why these properties aren't coming down the visual tree. Then it can be determined if this is the best fix or interum solution.

Things like this should have been caught before release.
I wonder if there shouldn't be some UI Test for customised control properties, to ensure the rendering matches the set properties?

I don't think there is a testing team anymore. This has been an ongoing problem for years now and is why software is getting buggier -- over-reliance on automated testing which assumes you understand all failure modes and have tests for them. In this case, I can't complain as it's now an open source project. Letting the community test and be involved for free is a benefit of open source.

I raised a lot of concerns about the way NumberBox v1 came to fruition. There were a great many bugs that shouldn't have been there: #1857 (comment) . We definitely need a test plan for controls so at least the original developer can run through it.

@marcelwgn
Copy link
Contributor Author

marcelwgn commented Jun 18, 2020

It seems that the properties get passed down to TextBlock, but not to a TextBox. The AutoSuggestBox for example, also needs TemplateBinding for those properties.

@StephenLPeters
Copy link
Contributor

It seems that the properties get passed down to TextBlock, but not to a TextBox. The AutoSuggestBox for example, also needs TemplateBinding for those properties.

@MikeHillberg is this expected?

@StephenLPeters
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@robloo
Copy link
Contributor

robloo commented Jun 18, 2020

I bet this is another bug with the TextBox then. Perhaps a new issue should be filed after this to be fixed with WinUI 3.0 -- TextBox needs a refactoring in my opinion.

@StephenLPeters
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@MikeHillberg
Copy link
Contributor

It seems that the properties get passed down to TextBlock, but not to a TextBox. The AutoSuggestBox for example, also needs TemplateBinding for those properties.

The text properties inherit until they're overridden by an element. They're not override by TextBlock (or any Panels), but many of the controls, such as TextBox, have a default style that overrides them with default values. AutoSuggestBox doesn't set default values for them, but its TextBoxStyle property defaults to the AutoSuggestBoxTextBoxStyle, which sets some text properties.

Copy link
Contributor

@StephenLPeters StephenLPeters left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@StephenLPeters StephenLPeters merged commit b4df2bd into microsoft:master Jun 30, 2020
Kinnara added a commit to Kinnara/ModernWpf that referenced this pull request Jul 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-NumberBox NumberBox Control team-Controls Issue for the Controls team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NumberBox Font size not change the text inside the editor
6 participants