WPF-Forge / Forge.Forms

Dynamically generated forms and dialogs in WPF
https://wpf-forge.github.io/Forge.Forms
MIT License
149 stars 30 forks source link

Window(options) not working from minimized window #38

Closed skadefro closed 4 years ago

skadefro commented 5 years ago

I'm trying to use your excellent product from within microsoft workflow foundation. I've created an activity that launches a window using a dynamic form. In normal operation I will minimize the UI when a workflow is running, so when a dialog, message box or window is opened you will need to force it to have focus. You can do that with window.Focus() or window.BringToFront() But for some reason, using WindowOptions.BringToFront does not work (or work as I would assume it was suppose to )

object model = Forge.Forms.FormBuilding.FormBuilder.Default.GetDefinition(xmlString);
var options = new Forge.Forms.WindowOptions();
options.TopMost = true; options.BringToFront = true;
var _result = Forge.Forms.Show.Window(options).For<object>(model);

This works perfectly if the calling window is NOT minimized. But if the window is minimized 1) I need to manually click the new window in the task bar, or alt-tab too it 2) when i mouse over the window, the cursor shows a loading icon for 10-15 seconds 3) topmost is not respected.

Sub request, could we get an options.ScrollViewer , so if the form cannot fit inside the window, you get a scroll bar ?

edongashi commented 5 years ago

@skadefro I tried to fix the window activation in ae56fd894f9df6c9f493735639ccdbf8f6edf0fa but it still decides to ignore the popup under some conditions. Could you please test it in your environment and let me know if you can figure anything out?

The scroller currently works only in XML. If you wrap your content in a <layout maxHeight="..."> it will display a vertical scrollbar if the content exceeds that number:

image

You can wrap your whole form in a layout or you can leave your buttons out of it such that they are always visible.

skadefro commented 5 years ago

The update worked :-) A little weird ux thing, the window does not have focus, but the cursor is blinking in the first textbox. ( look how the cursor is blinking inside both windows, and textpad is receiving input ) ( at first i though it might be a timing issue (me minimizing while the dialog was opening so added a 500ms delay, still same issue ) Untitled

edongashi commented 5 years ago

Thanks for the help. Looks like the window is getting logical focus but not keyboard focus. I'll try playing with Keyboard.Focus(...) later.

edongashi commented 5 years ago

Hey @skadefro. Sorry for getting back so late. I added Keyboard.Focus(window) but I'm not sure if this will fix the issue. I tested by setting delayed dialogs but I can type right away with or without that line of code. If you can please try it and see if it works better now. Thank you.

edongashi commented 5 years ago

If possible try it with an XML form and then a class form and see if the behavior is the same for both cases. If not then it's possible that the initial focus thing is not working for XML.

skadefro commented 4 years ago

I think we can close this, i have a working solution, without using Forge.Forms.Show.Window. Let me know if you make any changes to Window, then I'll gladly try it again