public static void SetTitleBinding(object documentContentView, DependencyProperty property, FrameworkElement target, bool convertToString = false)
        {
#if !SILVERLIGHT && !NETFX_CORE
            target.SetBinding(TitleListenProperty, new Binding()
            {
                Source = target, Path = new PropertyPath(property), Mode = BindingMode.OneWay
            });
#endif
            object viewModel = ViewHelper.GetViewModelFromView(documentContentView);
            if (!DocumentViewModelHelper.IsDocumentContentOrDocumentViewModel(viewModel))
            {
                return;
            }
            if (DocumentViewModelHelper.TitlePropertyHasImplicitImplementation(viewModel))
            {
                Binding binding = new Binding()
                {
                    Path = new PropertyPath("Title"), Source = viewModel
                };
#if !SILVERLIGHT && !NETFX_CORE
                if (convertToString)
                {
                    binding.Converter = new ObjectToStringConverter();
                }
#endif
                target.SetBinding(property, binding);
            }
            else
            {
                new TitleUpdater(convertToString, viewModel, target, property).Update(target, viewModel);
            }
        }
        void OnPopup_Closing(CancelEventArgs e)
        {
#if DEBUG
            OnClosing(e);
#endif
            DocumentViewModelHelper.OnClose(ViewHelper.GetViewModelFromView(Content), e);
        }
 public bool Close(bool force = false)
 {
     if (!force)
     {
         var eventArgs = new CancelEventArgs();
         OnPopup_Closing(eventArgs);
         if (eventArgs.Cancel)
         {
             return(false);
         }
     }
     if (AsyncAction != null)
     {
         AsyncAction.Cancel();
     }
     Window.Current.CoreWindow.SizeChanged -= CoreWindow_SizeChanged;
     if (Popup != null)
     {
         DocumentViewModelHelper.OnDestroy(ViewHelper.GetViewModelFromView(Content));
         Popup.IsOpen = false;
         Popup        = null;
     }
     return(true);
 }
 object GetContent()
 {
     return(ViewHelper.GetViewModelFromView(documentContentView));
 }
 object GetViewModel(WindowBase window)
 {
     return(ViewHelper.GetViewModelFromView(window.Content));
 }
Example #6
0
 public static void SetViewModelDocumentOwner(DependencyObject view, IDocumentOwner documentOwner)
 {
     SetViewModelDocumentOwner(ViewHelper.GetViewModelFromView(view), documentOwner);
 }
Example #7
0
 public static void SetViewModelParentViewModel(DependencyObject view, object parentViewModel)
 {
     SetViewModelParentViewModel(ViewHelper.GetViewModelFromView(view), parentViewModel);
 }
Example #8
0
 public static void SetViewModelParameter(DependencyObject view, object parameter)
 {
     SetViewModelParameter(ViewHelper.GetViewModelFromView(view), parameter);
 }
Example #9
0
 static object GetParameterCore(DependencyObject d)
 {
     return(ViewHelper.GetViewModelFromView(d).With(x => x as ISupportParameter).Return(x => x.Parameter, null));
 }
Example #10
0
 static void SetDocumentOwnerCore(DependencyObject d, IDocumentOwner documentOwner)
 {
     ViewHelper.GetViewModelFromView(d).With(x => x as IDocumentContent).Do(x => x.DocumentOwner = documentOwner);
 }
Example #11
0
 static void SetParentViewModelCore(DependencyObject d, object parentViewModel)
 {
     ViewHelper.GetViewModelFromView(d).With(x => x as ISupportParentViewModel).Do(x => x.ParentViewModel = parentViewModel);
 }
Example #12
0
 static void SetParameterCore(DependencyObject d, object parameter)
 {
     ViewHelper.GetViewModelFromView(d).With(x => x as ISupportParameter).Do(x => x.Parameter = parameter);
 }
Example #13
0
 static IDocumentOwner GetDocumentOwnerCore(DependencyObject d)
 {
     return(ViewHelper.GetViewModelFromView(d).With(x => x as IDocumentContent).Return(x => x.DocumentOwner, null));
 }
 protected Style GetDocumentContainerStyle(DependencyObject documentContainer, object view, Style style, StyleSelector styleSelector)
 {
     return(style ?? styleSelector.With(s => s.SelectStyle(ViewHelper.GetViewModelFromView(view), documentContainer)));
 }
Example #15
0
 public static IDocumentOwner GetDocumentOwner(DependencyObject obj)
 {
     return((IDocumentOwner)obj.GetValue(DocumentOwnerProperty) ??
            ViewHelper.GetViewModelFromView(obj).With(x => x as IDocumentContent).Return(x => x.DocumentOwner, null));
 }
Example #16
0
 public static object GetParentViewModel(DependencyObject obj)
 {
     return(obj.GetValue(ParentViewModelProperty) ??
            ViewHelper.GetViewModelFromView(obj).With(x => x as ISupportParentViewModel).Return(x => x.ParentViewModel, null));
 }