locked
WPF dialog from a package centered to Visual Studio RRS feed

  • Question

  • Hi there,

    I'm displaying a WPF dialog from my package. It should be centered to it's parent, the Visual Studio instance.

    Is there a way to achieve this? I haven't found a way to get to an instance I can surpass the Show method.

    Thanks,
    Fabian


    The Visual Studio Settings-Switcher! Visit http://visualstudiogallery.msdn.microsoft.com/a79072f7-3109-44a0-95c0-9c50e729d6a3

    Monday, October 20, 2014 6:40 PM

Answers

  • You can center a WPF dialog with following code:

    dialog.Owner = System.Windows.Application.Current.MainWindow;

    dialog.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner;



    Sergey Vlasov | Vlasov Studio | Visual Studio add-ins, extensions and tools

    • Marked as answer by Twainsoft Tuesday, October 21, 2014 1:56 PM
    Tuesday, October 21, 2014 4:13 AM

All replies

  • You can center a WPF dialog with following code:

    dialog.Owner = System.Windows.Application.Current.MainWindow;

    dialog.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner;



    Sergey Vlasov | Vlasov Studio | Visual Studio add-ins, extensions and tools

    • Marked as answer by Twainsoft Tuesday, October 21, 2014 1:56 PM
    Tuesday, October 21, 2014 4:13 AM
  • Hi,

    thanks for your answer. Seems to work. My WPF dialog is on top of the Visual Studio instance.

    Bye,
    Fabian


    The Visual Studio Settings-Switcher! Visit http://visualstudiogallery.msdn.microsoft.com/a79072f7-3109-44a0-95c0-9c50e729d6a3

    Tuesday, October 21, 2014 1:56 PM