I am trying to use different things using MVVM. In our ViewModel properties that are bound to the View are publicly available. I take an example of button binding. Here is a simple example.
View.xaml:
<Button Content="Test Button" Command="{Binding TestButtonCommand}" />
ViewModel.cs
private ICommand _testButtonCommand; public ICommand TestButtonCommand { get { return _testButtonCommand?? (_testButtonCommand= new RelayCommand(SomeMethod)); } }
Here's my question: can we make TestButtonCommand internal, not public? Internal means that it is available for the current project, so shouldn't they be a problem? But when I tried to do this, it did not work. Adding a breakpoint to the getter has not been removed. So why can't we make this internal.
Here is the link from msdn.
http://msdn.microsoft.com/en-us/library/ms743643.aspx
The properties that you use as properties of the binding source for the binding must be public properties of your class. Explicit interface properties cannot be accessed for binding purposes, and private, internal, or virtual properties that do not have a basic implementation cannot be protected.
Why can't we do this? In the case of access, the internal one is the same as public, if it works in the same project. Then why can't we use the internal ones here. There must be a reason that they should be publicly available, and I'm looking for this reason.
internal ICommand TestButtonCommand { ...... }
source share