JackyDoe JackyDoe - 1 year ago 112
C# Question

Equivalent to WebBrower.ShowPageSetupDialog in WPF

I was using a Form WebBrowser and I want to make my application in WPF.

So I use WPF WebBrowser but there is no function ShowPageSetupDialog.

Is there an equivalent ?

Answer Source

See : https://msdn.microsoft.com/en-us/library/ms751761.aspx?f=255&MSPPError=-2147217396

Add this on your Windows :

public partial class yourWindow : Window
    System.Windows.Forms.WebBrowser formWebBrowser = null;

    private void Window_Loaded(object sender, RoutedEventArgs e)
        // Create the interop host control.
        System.Windows.Forms.Integration.WindowsFormsHost host =
                new System.Windows.Forms.Integration.WindowsFormsHost();

        // Create the MaskedTextBox control.
        formWebBrowser = new System.Windows.Forms.WebBrowser();

        // Assign the MaskedTextBox control as the host control's child.
        host.Child = formWebBrowser ;

        // Add the interop host control to the Grid
        // control's collection of child controls.

After that you can use formWebBrowser.ShowPageSetupDialog();