3
votes

I have a WPF application with two windows, MainWindow and Window2. MainWindow was created by Visual Studio (and then modified by me). I then right-clicked on my project and chose Add -> Window. I modified the new window XAML and added a button to my main page with this click handler:

    private void OnTest(object sender, RoutedEventArgs e)
    {
        var tst = new Window2();
        tst.Show();
    }

Clicking on the button with that handler results in an exception being thrown:

System.Windows.Markup.XamlParseException: 'The visual tree has been changed during a 'VisualTreeChanged' event.'

The line that threw the exception is

tst.Show();

Obviously, I'm missing something basic, but I have no idea what it is.

1
It only occurred to me when I updated my Windows 10 to Fall Creators Update Insider Preview version.walterlv

1 Answers

15
votes

I think i know what is it. Maybe this will help you. You can also try this

Tools -> Options -> Debugging -> General ->Uncheck: Enable UI Debugging Tools for XAML