In my application I have certain ContentViews that need to take an action when they become visible (namely load their data). There are several events in the system that can cause them to become visible, so tying the load data operations to those is problematic as many of those events can occur one after the other. If I had a way to simply load the data when the Visible property turns "true", then I will be in a much better place.
I created a simple example of what I am trying to accomplish. Namely I need the ContentView to generate an event when the Visible property changes. It doesn't work, but I think it's close and I would appreciate someone showing me how to make it work. If I can get this example to work, then I can wrap all of my ContentViews that need this functionality in a base ContentView that delivers the event I am needing.
All the code can be found on GitHub here. If helpful, you can download the code to see the entire solution.
First I have a PanelView control defined. Notice I am binding the IsVisible property to a PanelVisible property in the code behind...
Then in the code behind I have two BindableProperty props, PanelVisibleProperty and ShowingProperty. PanelVisible is bound to IsVisible from above. On the propertyChanged event, I am invoking the Showing Command.
In my MainPage.xaml I have a button which when clicked invokes the ShowPanelView Command which sets the PanelViewVisible property and makes the PanelView display (initially hidden upon load). And, I bind the Showing Command from the PanelView to the PanelShowing Command in the model.
And finally, here is the MainPageModel that is bound to the page...
I am not getting a propertyChanged event here, and if I can get that to happen, then I think the rest of it would work fine.
Can anyone see what the issue is? Much thanks!




