Esempio n. 1
0
 static void OnParameterChanged(DependencyObject d, object newValue)
 {
     if (NotSetParameter == newValue)
     {
         return;
     }
     ViewModelInitializer.SetViewModelParameter(d, newValue);
     ParameterAndParentViewModelSyncBehavior.AttachTo(d);
 }
Esempio n. 2
0
 public static void InitializeView(object view, object viewModel, object parameter, object parentViewModel, IDocumentOwner documentOwner = null)
 {
     if (documentOwner is DependencyObject)
     {
         documentOwner = DocumentOwnerWrapper.Create(documentOwner);
     }
     if (viewModel != null)
     {
         ViewModelInitializer.SetViewModelProperties(viewModel, parameter, parentViewModel, documentOwner);
         view.With(x => x as FrameworkElement).Do(x => x.DataContext        = viewModel);
         view.With(x => x as FrameworkContentElement).Do(x => x.DataContext = viewModel);
         view.With(x => x as ContentPresenter).Do(x => x.Content            = viewModel);
         return;
     }
     if (view is DependencyObject)
     {
         ViewModelInitializer.SetViewModelProperties((DependencyObject)view, parameter, parentViewModel, documentOwner);
     }
 }
Esempio n. 3
0
 static void OnDocumentOwnerChanged(DependencyObject d, IDocumentOwner newValue)
 {
     ViewModelInitializer.SetViewModelDocumentOwner(d, newValue);
     ParameterAndParentViewModelSyncBehavior.AttachTo(d);
 }
Esempio n. 4
0
 static void OnParentViewModelChanged(DependencyObject d, object newValue)
 {
     ViewModelInitializer.SetViewModelParentViewModel(d, newValue);
     ParameterAndParentViewModelSyncBehavior.AttachTo(d);
 }
Esempio n. 5
0
 void OnAssociatedObjectDataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
 {
     ViewModelInitializer.SetViewModelParameter(AssociatedObject, GetParameter(AssociatedObject));
     ViewModelInitializer.SetViewModelParentViewModel(AssociatedObject, GetParentViewModel(AssociatedObject));
     ViewModelInitializer.SetViewModelDocumentOwner(AssociatedObject, GetDocumentOwner(AssociatedObject));
 }