c# - WPF User Control full sreen on maximize? -
i have window , inside window, have usercontrol. want maximize or expand (to full screen) user control on hit of f11. existing code works window,
if (e.key == key.f11) { windowstyle = windowstyle.none; windowstate = windowstate.maximized; resizemode = resizemode.noresize; } but need have feature usercontrol. there similar way maximize user control? please give me suggestions. thanking in advance.
there no such thing user controls.
there 2 things can think not sure want achieve.
1) want full screen without window toolbar , in order have call pinvokes
wpf doesn't have built-in property hide title bar's close button, can few lines of p/invoke.
first, add these declarations window class:
private const int gwl_style = -16; private const int ws_sysmenu = 0x80000; [dllimport("user32.dll", setlasterror = true)] private static extern int getwindowlong(intptr hwnd, int nindex); [dllimport("user32.dll")] private static extern int setwindowlong(intptr hwnd, int nindex, int dwnewlong); put code in window's loaded event: var hwnd = new windowinterophelper(this).handle; setwindowlong(hwnd, gwl_style, getwindowlong(hwnd, gwl_style) & ~ws_sysmenu); and there go: no more close button. won't have window icon on left side of title bar, means no system menu, when right-click title bar -- go together.
note alt+f4 still close window. if don't want allow window close before background thread done, override onclosing , set cancel true.
2) want show user control in dialog have use window class , put usercontrol inside child
what have correct windows, yes. if that's not case can think aiming first one?
Comments
Post a Comment