使用WPF行为时 - 使用为AssociatedObject.DataContext定义的ViewModel是一种很好的做法(MVVM方面)吗?就像行为中的这个事件处理程序一样:
private void Plate_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
UserControl userControl = AssociatedObject as UserControl;
Border borderParent = userControl.Parent as Border;
PlateViewModel plateViewModel = userControl.DataContext as PlateViewModel;
plateViewModel.ElementSelectedItem.Caption = "Selected Item";
}