Replies: 1 comment 1 reply
-
"Closing" a view is removing it from the region. The navigation API is not used for removing views, only the Region API allows you to remove a view from a region. Your "tile" control should be handling removing the view form the region when you "Close" the tile. It's the same concept that I cover in my Mastering the TabControl course on Pluralsight which shows you how to "close" a tab and remove the view form the region. Watch it here: https://pluralsight.pxf.io/B6X99 |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi, is there a reason there is no built in way to close a view from the view model? Often you may want to send up confirmation or possibly control on a can execute when they can close, so makes sense to go through the View Model and for it to handle it?
My exact example is that I have an all active region, which is basically like the windows start menu (current) with tiles and the user unpins these to close.
At the moment I am removing the view from the region by matching on the DataContext being the ViewModel of the one that wants to be closed but this is quite legacy code and does seem quite dodgy. I could interface them up and do a similar thing but ideally this would be done on some kind of service? Possibly the RegionManager or Navigation service could offer up a close? Which uses the VM to maybe close?
As it currently is, it is not the best Unit Testable code, or requires a bit of setup.
What are the thoughts on this?
Beta Was this translation helpful? Give feedback.
All reactions