У меня есть UserControl с Dependency собственности:Как связать свойство DependencyProperty в UserControl с свойством DataContext? Windows Store
public static readonly DependencyProperty Step2CommandProperty =
DependencyProperty.Register("Step2Command", typeof(ICommand), typeof(MyTripNavigationStep), new PropertyMetadata(null));
public ICommand Step3Command
{
get { return (ICommand)GetValue(Step3CommandProperty); }
set { SetValue(Step3CommandProperty, value); }
}
Тогда у меня есть ViewModel со свойством ICommand:
public ICommand SaveStep1Command
{
get
{
return new RelayCommand(() =>
{
});
}
}
Тогда я связываю эти два свойства, как это на странице, где я иметь viewModel как DataContext и UserControl.
<UserControls:Step Step3Command="{Binding SaveStep1Command, Mode=OneWay}" />
Связывание не применяется, и Step3Command в UserControl всегда, как представляется, быть пустым. Я знаю, что DataContext работает нормально, и что Visual Studio не позволяет мне привязывать TwoWay. Я использую обновление GalaSoft Simple Mvvm и Visual Studio CTP 2.
У кого-нибудь есть ключ к тому, что я делаю неправильно? Благодарю.