Closed joshman1019 closed 4 years ago
Attached are a series of screenshots where I am inspecting the Content property, and am receiving conflicting results.
@joshman1019 Could you push the demo code to GitHub? An isolated repo would help.
Closing issue as (no matter how deep I dug) I missed the fact that I was attempting to cast to a BasePage when I had created a "BasePage<
@joshman1019 LOL
Version: .Net Core 3.1, Development Environment: Visual Studio 2019 Community WPF-MVVM Pattern When attempting to assign System.Windows.Controls.Frame.Content property to a new variable, I am receiving a NullReferenceException, which does not occur in .Net Framework 4.7.1.
The following is an exact copy of my StackOverflow question which has yielded no answers:
I am developing a WPF application using .Net Core 3.1 (MVVM pattern), and I have run across an issue that I have never had in .Net framework on other applications I've developed.
My main window has a frame which hosts the various pages within my application. That frame's content is set by a "PropertyChanged" event fired by the application viewmodel. I am doing it this way, instead of binding directly to the CurrentPage property, because I want to call an animation that fades out the page prior to the next one being loaded.
My application viewmodel looks like this: (NOTE: BaseViewmodel inherits INotifyPropertyChanged and I use PropertyChanged.Fody to handle the property change events)
My application's main window has a frame component named BaseFrame. That frame's content is set initially by the viewmodel and window constructor. After being initially set, I have subscribed to the PropertyChanged event on the viewmodel, and am specifically watching for CurrentPage to be changed. Once that occurs, the page is supposed to animate out (if a previous page exists within the frame) and then load in the next page. I usually handle this by creating a variable containing the current content, await the animate out, and then allowing the content to be updated. (NOTE: The enum ApplicationPageTypes is extended in my UI project, which fetches the proper page. You will see this extension method called within the window's interaction logic.)
My window's interaction logic looks like this:
My current BasePage, which all other pages inherit, looks like this:
My problem is that when stepping through, the BaseFrame.Content property passes the first null check, but then fails with a NullReferenceException when I assign the content to a variable.