Hello,
We have been using UltraGrid for a while for developing WinForms MDI applications. Recently we replaced top level UI layer with WPF application. That created a weird issue of automatically closed drop down inside UltraGrid. I created small stand alone application to reproduce the problem. The application consists of top level WPF window hosting WinForms form defined as MDI container. This form contains another WinForm, so UltraGrid basically added to the controls of this form. The UltraGrid defines some columns with DropDownList style and uses UtraDataSource. The application compiles with Infragistic4.Win.v14.1 assemblies. The UltraGrid control is showed and populated correctly including drop down lists. However, when a drop down opened, it automatically closes after a small timeout that occurs inside Infragistics code.
If it helps, I can provide the sources of the stand alone application to demonstrate the problem.
So far it seems to be the only issue with the current architecture, so we need a workaround for this problem.
Thanks,
Leo.
In general WPF do not support MDI forms and hosting of top level Windows Forms Form is not supported of WindowsFormsHost. Based on this I assumed that you have made your custom panel with MdiClien in it, in order to simulate MdiParentFrom. But this scenario is not supported of Microsoft. Also I don’t understand why you should do all of this just to wrap your MdiParen into WPF window. What is the benefit to do this if you are actually use WinFroms and you do not migrated anything to WPF ? So it is not exactly a support by Infragisitcs scenario, but if you post small sample demonstrating this issue, we will look into it.
Some more explanation about what I’ve suspect happens here: our dropdowns uses DropDownManager who managed when and how dropdowns will be shown, but in this complicated scenario, I assume that it detects that focus is no longer onto the grid and that is why it close the dropdown. In the scenario like this it is possible we not know when grid will gets and loose the focus, since it will be wrapped by MdiClient, which is not hosted into a form (this could cause a bunch of issues regarding active forma, active control and etc.) and this will be hosted into a WindowsFormsHost, which also could cause issues with the focus and etc.
I am waiting for your feedback.
Hi,
Yes, we understand the complexity of this scenario. But this is the most effective way to use legacy WinForms application inside newer WPF shell that contains other WPF controls. Otherwise major refactoring is required to convert MDI-based existing layout to WPF. So we would be happy to get a workaround to our current problem.
That`s right, we use a derived from HwndHost class to host MDI parent form. Please see below the code of this class, the rest of the sample is straightforward.
If there is an option to upload files, I could also send you full VS project.
public class TopLevelFormHost : HwndHost { private System.Windows.Forms.Form child; public System.Windows.Forms.Form Child { get { return child; } set { var ps = PresentationSource.FromVisual(this) as HwndSource; if (ps != null && ps.Handle != IntPtr.Zero) throw new InvalidOperationException("Cannot set the Child property after the layout is done."); child = value; } } protected override HandleRef BuildWindowCore(HandleRef hwndParent) { HandleRef childHwnd = new HandleRef(Child, child.Handle); SetWindowStyle(childHwnd.Handle, WindowStyles.WS_CHILD | GetWindowStyle(childHwnd.Handle)); WindowsFormsHost.EnableWindowsFormsInterop(); System.Windows.Forms.Application.EnableVisualStyles(); SetParent(childHwnd.Handle, hwndParent.Handle); return childHwnd; } protected override void DestroyWindowCore(HandleRef hwnd) { child.Dispose(); } public static readonly Int32 GWL_STYLE = -16; public static readonly UInt32 WS_CHILD = 0x40000000; [DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)] internal static extern IntPtr SetParent(IntPtr hWnd, IntPtr hWndParent); [DllImport("user32.dll")] internal static extern WindowStyles GetWindowLong(IntPtr hWnd, Int32 nIndex); [DllImport("user32.dll")] internal static extern UInt32 SetWindowLong(IntPtr hWnd, Int32 nIndex, UInt32 dwNewLong); internal WindowStyles GetWindowStyle(IntPtr hWnd) { return (WindowStyles)GetWindowLong(hWnd, GWL_STYLE); } internal void SetWindowStyle(IntPtr hWnd, WindowStyles windowStyle) { SetWindowLong(hWnd, GWL_STYLE, (UInt32)windowStyle); } }
[Flags] internal enum WindowStyles : uint { WS_OVERLAPPED = 0x00000000, WS_POPUP = 0x80000000, WS_CHILD = 0x40000000, WS_MINIMIZE = 0x20000000, WS_VISIBLE = 0x10000000, WS_DISABLED = 0x08000000, WS_CLIPSIBLINGS = 0x04000000, WS_CLIPCHILDREN = 0x02000000, WS_MAXIMIZE = 0x01000000, WS_BORDER = 0x00800000, WS_DLGFRAME = 0x00400000, WS_VSCROLL = 0x00200000, WS_HSCROLL = 0x00100000, WS_SYSMENU = 0x00080000, WS_THICKFRAME = 0x00040000, WS_GROUP = 0x00020000, WS_TABSTOP = 0x00010000, WS_MINIMIZEBOX = 0x00020000, WS_MAXIMIZEBOX = 0x00010000, WS_CAPTION = WS_BORDER | WS_DLGFRAME, WS_TILED = WS_OVERLAPPED, WS_ICONIC = WS_MINIMIZE, WS_SIZEBOX = WS_THICKFRAME, WS_TILEDWINDOW = WS_OVERLAPPEDWINDOW, WS_OVERLAPPEDWINDOW = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX, WS_POPUPWINDOW = WS_POPUP | WS_BORDER | WS_SYSMENU, WS_CHILDWINDOW = WS_CHILD, }
You could upload file , when you press “Reply” button, go to “Options” tab, click on “Add/Update” button and using “Browse…” button navigate to your zip files which you want to attach, and press “Save” button. Please note that we have an limit to a 4-5 MB for uploading.
I am waiting for your details.
The attached is VS solution to reproduce the problem.
Thank you for the provided sample. In order to investigate this further I’ve created support ticket for you in our issue tracing system. Your ticket id is CAS-151709-L6B4X2, and I will update you via the case as soon as I have more information for you.
Thank you for your collaboration on this matter.