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

Added BorderThickness attached DP for outlined date/time pickers #2805

Merged
merged 6 commits into from
Aug 17, 2022

Conversation

nicolaihenriksen
Copy link
Contributor

@nicolaihenriksen nicolaihenriksen commented Aug 5, 2022

Fix for #2737

This PR introduces 2 new assists types (DatePickerAssist and TimePickerAssist) which both contain attached DPs which can be used to set the inactive and active BorderThickness on the DatePicker/TimePicker using the outlined styles (MaterialDesignOutlinedDatePicker/MaterialDesignOutlinedTimePicker). "Inactive" is when there is no mouse/keyboard interaction with the element, and "Active" is when the element is either hovered or has keyboard focus.

For the TimePicker, I could have just added the new attached DPs directly as normal DPs on the TimePicker type, but since the properties only apply for the outlined style, I thought it was better to keep them in a TimePickerAssist type.

I updated the demo app to include some samples of this because using Thickness values that vary from the default values may require the caller to also set the HintAssist.FloatingOffset in order for the hint to be correctly placed.

The IMultiValueConverter that I added is needed to calculate a "margin diff" which ensures the UI does not "jump" between the inactive/active states. This was previously hardcoded to -1 because the of the defaults being inactive=1 and active=2.

NOTE: In the UI tests I have left a TODO because I would have liked to be able to mark a ValidationError on the contained TextBox without too much overhead. Perhaps this is something that could be added as a feature in XAMLTest? For now, the tests include an actual ValidationRule and the value is changed during the test to force the validation error. I added a PR with proof-of-concept for this in the XAMLTest project.

Tests are running green locally, so I presume it has something to do with the delay being too short
Initial mouse position was on the pickers, so I added a dummy button to initially move the mouse position away from the pickers.
Ideally I would like XAMLTest to allow me to set a ValidationError "on the fly" if possible. For now, tests are updated with a real ValidationRule and invalid values are set to provoke the validation error.
@Keboo Keboo added this to the 4.6.0 milestone Aug 12, 2022
@Keboo Keboo added enhancement release notes Items are likely to be highlighted in the release notes. labels Aug 12, 2022
await Task.Delay(50); // Wait for the visual change
var focusedBorderThickness = await datePickerTextBox.GetProperty<Thickness>(Control.BorderThicknessProperty);

// TODO: It would be cool if a validation error could be set via XAMLTest without the need for the Binding and ValidationRules elements in the XAML above.
Copy link
Member

Choose a reason for hiding this comment

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

This is a good request. I will have to look into what that API could look like. I typically have done that by building out a custom control in the test project (as this then supports things like code behind, view models, etc). But I can certainly see a desire to not have to jump through all of those hoops.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a good request. I will have to look into what that API could look like. I typically have done that by building out a custom control in the test project (as this then supports things like code behind, view models, etc). But I can certainly see a desire to not have to jump through all of those hoops.

Cool! As mentioned in the PR, I already have a proof-of-concept PR in the XAMLTest library with one approach to adding this type of functionality. Looking forward to seeing how you would approach it.

@Keboo Keboo merged commit e133232 into MaterialDesignInXAML:master Aug 17, 2022
@nicolaihenriksen nicolaihenriksen deleted the fix2737 branch August 17, 2022 06:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement release notes Items are likely to be highlighted in the release notes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants