Expose the properties of a usercontrol which is built in MVVM

Viewed 1598

There are lots of questions like this one, but still can't get what I really want, and all of them have something that differs of mine and that is: I have a UserControl:

  • Built separately in a class library project called UCProject;
  • The project UCProject has a View for the control, and its ViewModel;
  • The UserControl binds some of its own controls and UIElements properties in the View to properties declared in the ViewModel in, of course, the UCProject;
  • How can I show or expose or make the ViewModel Properties accessible to the page or the window of the project (that may be called for instance GlobalProject) that may host this UserControl;

I'am building this UserControl, I want to build events, properties to it ... and I want it to be used by others as a given assembly to them, so its code is not accessible, they only can consume it, I want to respect the MVVM pattern, and I don't have a clear idea how to realize that, should I write this properties and events in the CodeBehind of the UserControl View or should I put them in the ViewModel, and in that case how can I access them from outside, just like we daily use third-party controls

3 Answers
Related