[WPF] Easily Customize a PopUpWindowAction Window
I have had a brief talk with Brian and he suggested I posted my idea as an issue so the whole community could benefit and opinion on it.
My problem is, Prism's PopUpWindowAction gives back a resizable Window and can have 0 Height and Width, and in my project I want a Window with a fixed sized and not resizable, so how to achieve this?
I have had some ideas, and here they are:
- Make
PopUpWindowActionaccept also aWindow, and not only aWindowContent. In this case, if the user provides aWindowas theContent,PopUpWindowActionwill create a newWindowbased on the user's givenWindow.This way the user can fully customize in xaml hisWindow, and use it withPopUpWindowAction. - Make
PopUpWindowActionaccept a new dependancy property calledWindowStyleso the user can provide a style to be applied in theWindowto be created. I personally think this is cleaner and simpler. - Use both and let the user decide what he likes most.
Currently, Prism 6 PopUpWindowAction has a method called CreateWindow() that can be overridden so you could create your own Window. But I think this is too much work to do (subclass and override for all your Windows with different Heights, Widhts and etc.), and it could be as simple as provide a Style, or a Window directly. Also, PopUpWindowAction's Invoke method has a line that makes:
wrapperWindow.SizeToContent = SizeToContent.WidthAndHeight;
Which will override the SizeToContent of the CreateWindow() anyways, making the override not a fully customizable option.
I am willing to do these modifications to the library myself, but first I want to know the general opinion of the community, so I won't jump to code something that maybe goes against some architecture decision and won't be approved by the bar.
I think a Style property might be something to consider. I also think that the call to SizeToContent can be moved into the GetWindow method. Or better yet, add the SizeToContent property to both the DefaultConfirmationWindow and DefaultNotificationWindow objects in XAML, and also in the CreateWindow method before retuning the new Window instance. This way the size can be better controlled.
What about moving the SizeToContent property to both the DefaultConfirmationWindow and DefaultNotificationWindow objects in XAML (as you proposed), and also crate a DefaultWindow with the SizeToContent inside it as well and CreateWindow() now creates an instance of this DefaultWindow, instead of a Window, this way all the view's customizations can be threated in xaml.
I like the WindowStyle approach, I think it will suffice. Glad to see that I'm not the only one after this feature.
i also like the idea adding some DependencyProperties to the PopupWindowAction to customize the window. To solve a similar issue in my projects I created a sub-class here https://github.com/ronin4net/Plainion/blob/master/src/Foundation/Plainion.Prism/Interactivity/PopupViewAction.cs
it supports setting windowheight, windowwith and resizemode directly in Xaml.
Is it an option to contribute a "merged" solution to the library?
@ronin4net what do you mean by "Is it an option to contribute a "merged" solution to the library?" ?
The current PR #86 under review has a Style DP that will set the Style for the new Window, so the dependency properties you made will be redundant, since the same options can be set by providing the correct Style.
Agree with @feinstein here. The Style approach should cover most if not all bases. If there are specific things that cannot be set through the Style, let us know and we will consider them. But trying to add individual dependency properties for specific things is a nearly bottomless pit - we are not going to try to cover every possible thing someone might want to customize that way. Especially because the architecture of interaction requests is already fully extensible - if you want to do something different than what the Prism implementation supports, write a custom behavior that starts with the code from Prism and does whatever specific thing you need to do. If you can convince us that there is a broad enough audience for that one thing, then we can consider pulling your behavior into Prism as an alternate strategy we support.
Oops, didn't mean to close there - leaving open until we implement the Style property.
Obviously I have not read the initial proposal carefully enough - of course the style approach would support my wish perfectly fine - sorry for the inconvenience :(
This Style property has been implemented.
Thank you very much for implementing Style property, it's saved my Day!
You are very much welcome :)
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.