[Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 351
  • Last Modified:

How do i get a viewmodel object to remove itself from its containing observable Collecttion?

I am building an application that has a ObservableCollection containing a bunch of UserControls.  The usercontrols are added because of a DataTemplate.  The object actually added to the collection is an MVVM view Model obejct.  

My usercontrol has a button on it that when pressed should cause itself to be removed from the list.  Now i can Implement this as an event by calling a custom event in the in the usercontrol code behind and catching it in another list object derived from the ObservableCollection.  but i would like to know if i can get the same behavior through the use of a command attachted to that button.
1 Solution
kmitch62Author Commented:
I got it.  simply created a new custom event in the ViewModel and updated the Observable list to catch the event when fired.

Had the command redirect to the method that raised the event then done.

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now