dimanche 28 juin 2015

How to make Control work for Forms?

I made a reuseable control for our little team in WPF: a simple Dialog, that we use often. The handling of the window is done in a private method:

private static void ExecuteInternal(
        Window owner,
        string windowTitle,
        string label,
        object operation,
        MyDialogSettings settings)
    {
        MyDialog dialog = new MyDialog(windowTitle, settings);
        dialog.Owner = owner;
        dialog.Label = label;

        ShowDialog();
    }

The public call has a System.Windows.Window as parameter (--> WPF Window) and my function sets the Owner to this window. Now my colleage wants to use this Window from a Windows Forms application.

My first thought was to overload the public function call with a form and then handle it with the WindowInteropHelper internally (see: http://ift.tt/1NiCTYk)

But I then would have to reference Windows.Forms in every (WPF)-Project that uses my library. Because I cannot access the window instance from outside the WindowInteropHelper-thing cannot done in the Forms application.

Any ideas?

Aucun commentaire:

Enregistrer un commentaire