WindowLogic and WindowBehavior flexiblity/improvements

Jun 4, 2012 at 11:10 AM

Hi Geert,

if you would change the System.Windows.Window type to a FrameworkElement type in the WindowLogic constructor one could use this class for windows which are not derived from System.Windows.Window but have the same properties/methods (DialogResult, Closed...) without duplicating catel code.

public WindowLogic(FrameworkElement targetWindow, Type viewModelType, IViewModel viewModel)

changing WindowBehavior into

class WindowBehavior : MVVMBehaviorBase<FrameworkElement, WindowLogic>

would also allow one to use this behavior for "windows" not derived from System.Windows.Window but with the same methods/properties.

these modifications do not break existing code....

thanks!

Jun 4, 2012 at 5:46 PM

This would be possible, but do you have any examples for this? For example, why would a frameworkelement based control have DialogResult and a Close method, but not derive from Window?

Jun 4, 2012 at 6:23 PM

The telerik RadWindow would fit perfectly into this scenario for the above modifications.

The RadWindow is not derived from System.Windows.Window but as the standard wpf window from Frameworkelement and it has also the following things:

- void Close()
- bool? DialogResult
- Closed Event

And since you are doing dynamic interaction with the things mentioned above, i could simply plugin the catel WindowBehavior into the RadWindow without any modifications. Currently i have two classes which are simply duplicates of the catel WindowLogic and WindowBehavior classes because they are tied to the System.Windows.Window type and not to the Frameworkelement type.

Jun 5, 2012 at 7:13 PM

Sounds fair. I will add this and release a new package tonight. If you encounter any issues, please let me know ASAP.

Jun 5, 2012 at 8:31 PM
Edited Jun 5, 2012 at 8:31 PM

New (beta) version is pushed to nuget, enjoy.

Jun 6, 2012 at 10:14 AM

The new version works perfectly but i forgot to mention one modification i did (sorry):

The telerik window does not call Close when setting the Dialogresult (so the window stays on screen).

It would be very helpful if could also introduce a bool ForceCloseAfterSettingDialogResult (or something else, default = false for backwards compatiblity) in the WindowBehavior which would dynamically call the Close method after setting the DialogResult if requested.

Many thanks!

Jun 6, 2012 at 9:50 PM

No problem, I know Telerik has their own "ideas" about UX ;)

Feature is implemented.

Jun 7, 2012 at 5:49 PM

you are very fast.... thanks a lot!