This project has moved and is read-only. For the latest updates, please go here.

Re-using a UserControl based in MVVM Light

Mar 29, 2012 at 4:18 PM

We are using MVVM light Toolkit in our Silverlight 5 project.

In our project we have a UserControl (using MVVM, so we have one XAML file for the view and one C# file for the ViewModel , that inherits from ViewModelBase).  I will call this UserControl like “ucSPFiles”

We have two instances of the same ucSPFiles userControl alive, because we have two XAML files (File_One.XAML and File_Two.XAML), that use the same ucSPFiles UserControl.

En each XAML file we named each UserControl like “SP_Files_Revision” and “SP_Files_General” respectively.




<myucrev:ucSPFiles x:Name="SP_Files_Revision" Visibility="{Binding …   >... </myucrev:ucSPFiles>




<myucrev:ucSPFiles x:Name="SP_Files_General" Visibility="{Binding …   >...</myucrev:ucSPFiles>


How from the ViewModel of the UserControl (ucSPFiles) I can get the x:Name of the instants of the each userControl in order to differentiate which control is using the ViewModel?  Important: that at the same time both instances of the usercontrol exist.