Exemple #1
0
 public static void Initialise(IEnumerable <Assembly> assembliesToExamine)
 {
     try
     {
         //now pass the same Assemblies to the ViewResolver so it can
         //resolve the workspace Types
         ViewResolver.ResolveViewLookups(assembliesToExamine);
         PopupResolver.ResolvePopupLookups(assembliesToExamine);
     }
     catch (Exception ex)
     {
         throw new InvalidOperationException("Bootstrapper.Initialise() failed", ex);
     }
 }
Exemple #2
0
        /// <summary>
        /// Handles changes to the ViewCreator property.
        /// </summary>
        private static void OnViewCreatorChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ItemsControl itemsControl = null;

            if (e.NewValue == null)
            {
                itemsControl = TreeHelper.TryFindParent <ItemsControl>(d);
                bool shouldHideHostWhenNoItems = (bool)itemsControl.GetValue(NavProps.ShouldHideHostWhenNoItemsProperty);
                if (shouldHideHostWhenNoItems)
                {
                    if (itemsControl != null)
                    {
                        itemsControl.Visibility = Visibility.Collapsed;
                    }
                }
                return;
            }

            Border        contPresenter = (Border)d;
            WorkspaceData viewNavData   = (WorkspaceData)e.NewValue;

            var theView = ViewResolver.CreateView(viewNavData.ViewLookupKey);

            viewNavData.ViewModelInstance = ((FrameworkElement)theView).DataContext;


            IWorkSpaceAware dataAwareView = theView as IWorkSpaceAware;

            if (dataAwareView == null)
            {
                throw new InvalidOperationException(
                          "NavProps attached property is only designed to work with Views that implement the IWorkSpaceAware interface");
            }
            else
            {
                dataAwareView.WorkSpaceContextualData = viewNavData;
                contPresenter.Child = (UIElement)dataAwareView;
            }
            itemsControl = TreeHelper.TryFindParent <ItemsControl>(d);
            if (itemsControl != null)
            {
                itemsControl.Visibility = Visibility.Visible;
            }
        }