I have a WPF application which opens a popup when the main window is loaded. The problem is when I select the .xaml file in the solution explorer in Visual Studio 2013, the popup "pops" even when the application is not running. I suppose it is an intended behavior since the visualizer needs to execute the code in order to render the page layout, but for now I need to close it every time I load the page... I cannot temporarily disable this popup since it has some start logic for the application (selection of a location,...).
Here is the code of the popup trigger
public GeneralProcess() //usercontrol
{
InitializeComponent();
Loaded += GeneralProcess_Loaded;
}
void GeneralProcess_Loaded(object sender, RoutedEventArgs e)
{
var popup = new StationSelect();
popup.Owner = Window.GetWindow(this);
popup.ShowDialog();
}
Is there a way to know if the application is running or if I am in the visualizer, or is there a way to disable the Loaded
event just for visual studio ? The goal is to still be able to see the page for easy editing.
EDIT : this question is a duplicate. However this answer worked for me.