Assuming a code like below,
public class SomeViewModel{
ICommand ReloadCommand{get...}
ICommand SaveCommand{get..}
}
//SomeView.xaml
<SomeCustomControl Reload="ReloadCommand" Save="SaveCommand" /> //NOT SURE HOW??
//SomeCustomContro.xaml
<SomeCustomControl x:Name="someCustomControl">
<Button Command={Binding ElementName=someCustomControl, Path=Reload />
<Button Command={Binding ElementName=someCustomControl, Path=Save />
</SomeCustomControl>
//SomeCustomControl.xaml.cs
..... //NOT SURE HOW TO ALLOW BINDING TO A ICOMMAND ??
In my SomeCustomControl, I need to support "binding of ICommand in xaml".
I understand DependencyProperties could be bind like this, but in this case I need to bind ICommand.
EDIT
I can use the DataContext SomeView in SomeCustomControl. There is more logic and separation between the two which I can not dissolve. I ‘must’ maintain a reference of Reload/Save ICommands somewhere in my SomeCustomControl.
Let me get you straight, you want to bind to the
ReloadandSaveright?So that needs creating, declaring and defining two dependency properties
ReloadCommandPropertyandSaveCommandPropertyof typeICommandforSomeCustomControl.So assuming that
SomeCustomControlderives fromControl…After this proper binding to
RelodCommandandSaveCommandproperties will start working…