我目前正在用MVVM模式写一个用户控件,它有一些属性,例如文件。如何在XAML中访问ViewModel的DependencyProperties?
的DependencyProperty在其中使用了用户控制
<control:ResultControl x:Name="myControl" />
我如何使用我的财产 “一号文件” 从视图模型绑定它们在XAML对视图模型
public static readonly DependencyProperty DocumentProperty = DependencyProperty.Register("Document", typeof(MyDocument), typeof(ResultControlViewModel), new PropertyMetadata(OnDocumentChanged));
public MyDocument Document
{
get { return (MyDocument)GetValue(DocumentProperty); }
set { SetValue(DocumentProperty, value); }
}
的MainView例如,MainView中的ListBox的选定项目?
Programmaticly。我可以在我的用户控件的代码隐藏中编写一个方法,但是我认为这不是实现这一目标的美丽方法。特别是关于使用MVVM模式。