First, I am new to WPF and MVVM. I have an Interface like this
Interface IItemType
{
bool save()
}
and I have three concrete classes which they are inherited from this Interface
Public Class Type1:IItemType
{
public bool save()
{
//save something with method 1
}
}
Public Class Type2:IItemType
{
public bool save()
{
//save something with method 2
}
}
I have three RadioButtons (they can extend in future to 4,5 or more) in my View which I want to choose the Save Method (Class Type1
or Type2
) by selecting one of these RadioButtons.
The question is how can I bind these Radios to my ViewModel to not violating the pattern designs like OCP and etc (as In future I want to add more types and Radios)?
Meet the MVVM best practice design?
** EDIT **
Imagine I have the following Property
Public IItemType CurrentType { get; set; }
I want to put the Class Type1
into CurrentType property when the first Radio is selected
and put the Class Type2
into CurrentType property when the second Radio is selected and so on.