Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="UserControlLogic"/> class.
        /// </summary>
        /// <param name="targetControl">The target control.</param>
        /// <param name="viewModelType">Type of the view model.</param>
        /// <param name="viewModel">The view model.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="targetControl"/> is <c>null</c>.</exception>
        /// <exception cref="ArgumentNullException">The <paramref name="viewModelType"/> is <c>null</c>.</exception>
        /// <exception cref="ArgumentNullException">The <paramref name="viewModelType"/> does not implement interface <see cref="IViewModel"/>.</exception>
        public UserControlLogic(UserControl targetControl, Type viewModelType, IViewModel viewModel = null)
            : base(targetControl, viewModelType, viewModel)
        {
            SupportParentViewModelContainers = true;
            CloseViewModelOnUnloaded = true;

#if NET || SL4 || SL5
            SkipSearchingForInfoBarMessageControl = DefaultSkipSearchingForInfoBarMessageControlValue;
            CreateWarningAndErrorValidatorForViewModel = DefaultCreateWarningAndErrorValidatorForViewModelValue;
#endif

            // NOTE: There is NO unsubscription for this subscription.
            // Hence target control content wrapper grid will be recreated each time content changes.
            targetControl.SubscribeToDependencyProperty("Content", OnTargetControlContentChanged);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="UserControlLogic"/> class.
        /// </summary>
        /// <param name="targetControl">The target control.</param>
        /// <param name="viewModelType">Type of the view model.</param>
        /// <param name="viewModel">The view model.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="targetControl"/> is <c>null</c>.</exception>
        /// <exception cref="ArgumentNullException">The <paramref name="viewModelType"/> is <c>null</c>.</exception>
        /// <exception cref="ArgumentNullException">The <paramref name="viewModelType"/> does not implement interface <see cref="IViewModel"/>.</exception>
        public UserControlLogic(UserControl targetControl, Type viewModelType, IViewModel viewModel = null)
            : base(targetControl, viewModelType, viewModel)
        {
            SupportParentViewModelContainers = true;
            CloseViewModelOnUnloaded = true;

#if NET || SL4 || SL5
            SkipSearchingForInfoBarMessageControl = DefaultSkipSearchingForInfoBarMessageControlValue;
            CreateWarningAndErrorValidatorForViewModel = DefaultCreateWarningAndErrorValidatorForViewModelValue;
#endif

            if (targetControl.Content == null)
            {
                targetControl.SubscribeToDependencyProperty("Content", OnTargetControlContentChanged);
            }
            else
            {
                CreateViewModelGrid();
            }
        }