-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Fix DatePicker to respect custom Width property #20487
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
Fix DatePicker to respect custom Width property #20487
Conversation
|
You can test this PR using the following package version. |
|
|
@cla-avalonia agree |
MrJul
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you!
|
You can test this PR using the following package version. |
|
You can test this PR using the following package version. |
|
I forgot to also update TimePicker, so I created a second PR for that. |
| BorderThickness="{TemplateBinding BorderThickness}" | ||
| CornerRadius="{TemplateBinding CornerRadius}" | ||
| IsEnabled="{TemplateBinding IsEnabled}" | ||
| MinWidth="{DynamicResource DatePickerThemeMinWidth}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does MinWidth still need to be specified?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure. But I realized that TimePicker has the same problem as the DatePicker, so I made a PR for that here, and I added a commit to it to add the MinWidth back, just in case.
…tton (#20487) Co-authored-by: Julien Lebosquain <[email protected]>
What does the pull request do?
Allows developers to set a custom
WidthonDatePickerwithout the content overflowing. Currently, the internalButtonhas a hardcodedMinWidthfromDatePickerThemeMinWidth(296px) that cannot be overridden, preventing compact DatePickers in narrower layouts.Related discussion: #15456
What is the current behavior?
When setting
Width="200"on a DatePicker, the content overflows because the internal Button enforcesMinWidth=296regardless of the control's Width setting.What is the updated/expected behavior with this PR?
Developers can now create compact DatePickers by setting
MinWidth="0":Default behavior is unchanged - DatePickers without explicit MinWidth still use the theme default (296px).
How was the solution implemented?
This allows the Button to shrink when the DatePicker's MinWidth is overridden, while maintaining backward compatibility.
How to test this new behavior:
Add to
samples/ControlCatalog/Pages/DateTimePickerPage.xaml:Workaround (for developers waiting for this fix)
Until this PR is merged, you can override the theme resources locally:
Breaking changes
None
Obsoletions / Deprecations
None
Fixed issues
Fixes #4862
Fixes #18592