Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void WpfUsercontrol_OnLoaded(object sender, RoutedEventArgs e)
- {
- Window window = Window.GetWindow(this);
- if (window != null)
- window.Closing += window_closing;
- Form form = this.Parent as Form;
- //Error: Cannot convert from System.Windows.DependencyObject to System.Windows.Forms.Form
- }
- var hwndSource = (HwndSource)PresentationSource.FromDependencyObject(this);
- var host = (ElementHost)Control.FromChildHandle(hwndSource.Handle);
- Form form = (Form)host.TopLevelControl;
Add Comment
Please, Sign In to add comment