예제 #1
0
        private static void InitializeViewInternal(IViewModel viewModel, object view, IDataContext context)
        {
            if (view == null)
            {
                return;
            }
            if (viewModel != null)
            {
                viewModel.Settings.Metadata.AddOrUpdate(ViewModelConstants.View, view);
                viewModel.Subscribe(view);
                if (context.GetData(InitializationConstants.CanDisposeView))
                {
                    ServiceProvider.AttachedValueProvider.SetValue(view, ViewManagerCreatorPath, null);
                }
            }

            if (viewModel != null || ApplicationSettings.ViewManagerClearDataContext)
            {
                ToolkitExtensions.SetDataContext(view, viewModel);
            }
            ReflectionExtensions.GetViewModelPropertySetter(view.GetType())?.Invoke(view, viewModel);
            if (viewModel == null)
            {
                (view as ICleanableView)?.Cleanup(context);
            }
            else
            {
                (view as IInitializableView)?.Initialize(viewModel, context);
            }
        }
예제 #2
0
        private static void InitializeViewInternal(IViewModel viewModel, object view)
        {
            if (view == null)
            {
                return;
            }
            if (viewModel != null)
            {
                viewModel.Settings.Metadata.AddOrUpdate(ViewModelConstants.View, view);
                viewModel.Subscribe(view);
            }

            if (viewModel != null || ApplicationSettings.ViewManagerClearDataContext)
            {
                ToolkitExtensions.SetDataContext(view, viewModel);
            }
            ReflectionExtensions.GetViewModelPropertySetter(view.GetType())?.Invoke(view, viewModel);
        }