Closed blakepell closed 4 years ago
I can't reproduce the said behavior with the provided XAML. Do you also see this in a newly created app?
I created a sample project and didn't have the issue, I have narrowed it down though. One thing I noticed was that if I started moving code out of my main windows Loaded event it was less noticeable and that made me think I might be blocking. I'm trying to look through my code to figure out if I have somewhere that I'm forcing the window to be visible (I haven't found it yet, but as it steps through the Loaded event it writes log messages a terminal in that window).
I did re-create the behavior in a round about way to try to test my theory (perhaps contrived because I forced a Show
on the window). I specifically showed the window here and then did a Thread.Sleep and it shows the panel open until the 3 seconds is up even though the IsPaneOpen
is set to false by default.
private async void Window_Loaded(object sender, RoutedEventArgs e)
{
this.Show();
Thread.Sleep(3000);
this.Title = "Done";
}
I should note that I don't think I'm calling Show()
in my program anywhere.
Got it! I assume I could bind these maybe (and probably should). I'm learning more WPF best practices as I go. The problem was I set the Height/Width of the window in the Loaded event (and that must show the Window).
These were the offending lines:
this.Height = App.Settings.AvalonSettings.LastWindowPosition.Height;
this.Width = App.Settings.AvalonSettings.LastWindowPosition.Width;
I have a SplitView on my main window defined as follows. It works very well in usage. The one issue I have is that regardless of what
IsPaneOpen
is set to it always renders open when the Window loads and then transitions to closed after about a second (whereas I would think setting it to closed in the markup would render it as closed from the start).Is there a way around this behavior and/or am I doing something incorrect or is this the intended behavior by design?