ContentDialog : make FullSizeDesired extends in both directions + define max dialog size as owner window size (with margin) instead of hardcoded max size
Description
When a contentDialog is display inside a Windows, I would like the size of the contentDialog to be the same as owner window, possibly wih a margin.
If owner window is resized, contentDialog has to be resized too.
The FullSizeDesired flag on ContentDialog only seems to stretch my dialog vertically, even if I set HorizontalAlignement to 'stretch'. Moreover, this doesn't allow to define a margin.
Moreover, a maximum size is defined for dialog (see ContentDialogMaxWidth...) which is a problem to me. Moreover, this maximum size is absolute and not a ratio of owner window. For me, the maximum size should be relative, and limited by the size of the owner window.
Suggested Solution
- make FullSizeDesired extends in both directions
- define max dialog size as owner window size (with margin) instead of hardcoded max size, and update max size if window size is modified
Alternative
No response
Contribution
Sorry, I can't help.
Additional Notes
No response
Validations
- [x] Check that there isn't already an issue that reports the same or similar problem.
- [x] Check that this is a request that is a feature or something we can take action on, and also this is not about the documentation. (Or please choose the right repo and template.)
- [x] This is one single feature, or a few features with the same core. (If you want to report multiple feature, please create one issue for every single feature.)
- [x] You've checked that this feature is unavailable yet in the latest version.( Keep in mind that we don't provide any support for old versions.)
- [x] You know that we can't guarantee that we will satisfy your request. This is not really our duty to do everything anyone asks for. Also, you will treat our staff, contributors, and other users with respect and kindness.
- [x] You're sure it's something to enhance with the library itself, not how you're using it. (If you are having issues using it and need help, please go to discussion.)
If you want the MaxWidth to be relative (like 80% of the window width), I think it's better to implement this logic manually yourself, as this doesn't really meet common uses, and it just makes no sense to add this (like, if i add this to ContentDialog, i have to add this to any other controls).
It seems that the MaxWidth is hardcoded into the styles, it's not. Using a DynamicResources means you can override the values from its parent. You can overwrite the value manually every time the window width changes, and it's very easy.
For example I have created a dialog in this way:
ContentDialog dialog = new ContentDialog();
dialog.Title = "Save your work?";
dialog.PrimaryButtonText = "Save";
dialog.SecondaryButtonText = "Don't Save";
dialog.CloseButtonText = "Cancel";
dialog.DefaultButton = ContentDialogButton.Primary;
dialog.Content = new ContentDialogContent();
To set the real MaxWidth, try this line:
dialog.Resources[ThemeKeys.ContentDialogMaxWidthKey] = double.PositiveInfinity;
The line above can be used anywhere, like before invoking ShowAsync, or resize event of the owner window. I believe that using a code-behind and manual logic will actually give you more control of this behavior.
Just don't forget that any DynamicResource can be easily overwritten if you want to, that is one of the reason we give more control to you guys than other UI libraries. Keep that in mind and you will find it more interesting and 'hackable'!
If this works for you, please let me know so that we can close this issue. If not, tell me more about your specific needs.
Thanks for your answer. Interesting point about dynamic resource modification.
For the moment, I have modified the template by code for my specific dialog, so I've managed to get when I want.
Anyway, the purpose of this task was to suggest changes.
If I limit my request to FullSizeDesired : - FullSizeDesired shoud extend in both directions + should ignore max dialog size + giving the possibility to provide a FullSizeDesired margin could be useful
Well, it makes no sense to let both asix grow while the official version of WinUI doesn't. So maybe here we can change the type of "FullSizeDesired" property, but that would break existing users. My idea is something like:
<ContentDialog FullSizeDesired="Both"/>
<ContentDialog FullSizeDesired="Horizontal"/>
<ContentDialog FullSizeDesired="Vertical"/>
<ContentDialog FullSizeDesired="None"/>
Since this is a breaking change of the API interface, we have to consider it very carefully.
Thank you. I didn't kno w there was a constraint to stay identical to WinUI. I though the purpose was just to create a graphical library.
In order no to introduce a breaking change, maybe you could add a FullSizeMode flag, and maybe a FullSize margin.