Prism icon indicating copy to clipboard operation
Prism copied to clipboard

[WPF] Easily Customize a PopUpWindowAction Window

Open feinstein opened this issue 11 years ago • 12 comments

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:

  1. Make PopUpWindowAction accept also a Window, and not only a WindowContent. In this case, if the user provides a Window as the Content, PopUpWindowAction will create a new Window based on the user's givenWindow.This way the user can fully customize in xaml his Window, and use it with PopUpWindowAction.
  2. Make PopUpWindowAction accept a new dependancy property called WindowStyle so the user can provide a style to be applied in the Window to be created. I personally think this is cleaner and simpler.
  3. 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.

feinstein avatar Jul 22 '15 17:07 feinstein

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.

brianlagunas avatar Jul 24 '15 20:07 brianlagunas

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.

feinstein avatar Jul 27 '15 19:07 feinstein

I like the WindowStyle approach, I think it will suffice. Glad to see that I'm not the only one after this feature.

erbatista avatar Aug 04 '15 19:08 erbatista

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?

plainionist avatar Aug 17 '15 11:08 plainionist

@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.

feinstein avatar Aug 17 '15 14:08 feinstein

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.

briannoyes avatar Aug 17 '15 18:08 briannoyes

Oops, didn't mean to close there - leaving open until we implement the Style property.

briannoyes avatar Aug 17 '15 18:08 briannoyes

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 :(

plainionist avatar Aug 21 '15 11:08 plainionist

This Style property has been implemented.

brianlagunas avatar Aug 25 '15 17:08 brianlagunas

Thank you very much for implementing Style property, it's saved my Day!

sharadverma810 avatar Aug 24 '17 08:08 sharadverma810

You are very much welcome :)

feinstein avatar Aug 24 '17 08:08 feinstein

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.

lock[bot] avatar Jan 30 '20 13:01 lock[bot]