Позвольте мне объяснить, что вы хотите связать с Reload
и Save
, верно?
Так что нужно создать, объявить и определить два свойства зависимости ReloadCommandProperty
и SaveCommandProperty
типаICommand
для SomeCustomControl
.
Предполагая, что SomeCustomControl
является производным от Control
...
public class SomeCustomControl : Control
{
public static DependencyProperty ReloadCommandProperty
= DependencyProperty.Register(
"ReloadCommand",
typeof (ICommand),
typeof (SomeCustomControl));
public static DependencyProperty SaveCommandProperty
= DependencyProperty.Register(
"SaveCommand",
typeof(ICommand),
typeof(SomeCustomControl));
public ICommand ReloadCommand
{
get
{
return (ICommand)GetValue(ReloadCommandProperty);
}
set
{
SetValue(ReloadCommandProperty, value);
}
}
public ICommand SaveCommand
{
get
{
return (ICommand)GetValue(SaveCommandProperty);
}
set
{
SetValue(SaveCommandProperty, value);
}
}
}
После этого правильная привязка к RelodCommand
и SaveCommand
свойствам начнет работать ...
<SomeCustomControl RelodCommand="{Binding ViewModelReloadCommand}"
SaveCommand="{Binding ViewModelSaveCommand}" />