How to use WPF dialogs in VSTO applications? RRS feed

  • Question

  • Hello:

    I am mostly familiar with WPF, the more powerful alternative to Windows Forms. The latter is fine for simple "Ok", "Cancel", etc. dialogs. I have used them often. However, now I need a fancier dialog, resizable with a custom DataGrid inside, XAML incantations. etc. Since the repertoire of items to add under a VSTO project is limited, I chose "Add New Item | User Control (WPF)" and took a lot of time setting up that User Control to full satisfaction. The problem is that I tried to instantiate it as follows:

    Tabular_UserControl tuc = new Tabular_UserControl ();
    tuc.ShowDialog();     // this does not exist

    Can one of those UserControls be used in a standalone manner? Or, should I create the typical VSTO Form and somehow encapsulate the UserControl inside it? How? Any other alternative?


    Note: Perhaps a more appropriate title for this post would be "How to host WPF Controls in Windows Forms".

    Tuesday, June 19, 2018 8:27 PM


All replies