Search code examples
c#wpfms-wordoffice-interop

How do I open a wpf window from word using C#?


I am working on a word (2010) addin project. In the ribbon, I have a settings button.

If I click on the settings button, it should open a wpf window (which will have the settings related UI).

How do I open a wpf window from word using C#?


Solution

  • var window = new System.Windows.Window();
    window.Content = new System.Windows.Controls.Button { Content = "Click me!" };
    window.Show();
    

    You need to reference the following assemblies:

    • PresentationCore.dll
    • PresentationFramework.dll
    • WindowsBase.dll