Ответ 1
Позвольте мне сказать вам прямо, вы хотите привязать к 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}" />