I am developing a WPF app which shows constantly updating values (X, Y, Z) from an accelerometer. When I work with the XAML to modify the window or even just to look at it in the designer, it shows the live stream of data constantly updating as if the program were running. Or rather, because the program is running (somehow - I don't know how).
Nifty as this is, it is causing the following problem. When I then really do run the program, I get all zeroes from the device. It seems like Visual Studio is consuming the data and will not let it get to my window. In order to make it stop, I have to
1. activate a different file in the editor (or just close the .xaml file), then
2. close and reopen visual studio.
Is there a better way to keep Visual Studio from doing this?
Edit Based on the answer offered by SLaKs, I have added the following:
I am now checking for the value of DesignerProperties.GetIsInDesignMode(this) as suggested, but a different problem now crops up. My MainWindow constructor now looks like this:
public MainWindow()
{
InitializeComponent();
var dc = this.TopGrid.DataContext as RawAccelStream_ViewModel;
if (DesignerProperties.GetIsInDesignMode(this) == false)
base.Background = Brushes.Bisque;
else
{
base.Background = Brushes.Blue;
dc.Dispose();
}
}
The new problem is that with this code, when running the application the window background appears Bisque, but no color change happens at all in Designer View. And Designer View still shows values and still spoils the application instance of the window.