当前位置: 首页>>代码示例>>C#>>正文


C# IView.SubscribeToPropertyChanged方法代码示例

本文整理汇总了C#中IView.SubscribeToPropertyChanged方法的典型用法代码示例。如果您正苦于以下问题:C# IView.SubscribeToPropertyChanged方法的具体用法?C# IView.SubscribeToPropertyChanged怎么用?C# IView.SubscribeToPropertyChanged使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IView的用法示例。


在下文中一共展示了IView.SubscribeToPropertyChanged方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UserControlLogic

        /// <summary>
        /// Initializes a new instance of the <see cref="UserControlLogic"/> class.
        /// </summary>
        /// <param name="targetView">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="targetView"/> is <c>null</c>.</exception>
        public UserControlLogic(IView targetView, Type viewModelType = null, IViewModel viewModel = null)
            : base(targetView, viewModelType, viewModel)
        {
            if (CatelEnvironment.IsInDesignMode)
            {
                return;
            }

            SupportParentViewModelContainers = true;
            CloseViewModelOnUnloaded = true;
            UnloadBehavior = DefaultUnloadBehaviorValue;

#if !XAMARIN
            TransferStylesAndTransitionsToViewModelGrid = DefaultTransferStylesAndTransitionsToViewModelGridValue;
#endif

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

#if XAMARIN
            CreateViewModelWrapper(false);
#else
            // NOTE: There is NO unsubscription for this subscription.
            // Hence target control content wrapper grid will be recreated each time content changes.
            targetView.SubscribeToPropertyChanged("Content", OnTargetControlContentChanged);
#endif

            this.SubscribeToWeakGenericEvent<ViewLoadEventArgs>(ViewLoadManager, "ViewLoading", OnViewLoadedManagerLoadingForParentView);
            this.SubscribeToWeakGenericEvent<ViewLoadEventArgs>(ViewLoadManager, "ViewUnloading", OnViewLoadedManagerUnloadingForParentView);
        }
开发者ID:rishabh8,项目名称:Catel,代码行数:39,代码来源:UserControlLogic.cs

示例2: LogicBase

        /// <summary>
        /// Initializes a new instance of the <see cref="LogicBase"/> class.
        /// </summary>
        /// <param name="targetView">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="targetView"/> 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>
        protected LogicBase(IView targetView, Type viewModelType = null, IViewModel viewModel = null)
        {
            Argument.IsNotNull("targetView", targetView);

            if (viewModelType == null)
            {
                viewModelType = (viewModel != null) ? viewModel.GetType() : _viewModelLocator.ResolveViewModel(targetView.GetType());
                if (viewModelType == null)
                {
                    var error = string.Format("The view model of the view '{0}' could not be resolved. Make sure to customize the IViewModelLocator or register the view and view model manually", targetView.GetType().GetSafeFullName());
                    Log.Error(error);
                    throw new NotSupportedException(error);
                }
            }

            UniqueIdentifier = UniqueIdentifierHelper.GetUniqueIdentifier<LogicBase>();

            Log.Debug("Constructing behavior '{0}' for '{1}' with unique id '{2}'", GetType().Name, targetView.GetType().Name, UniqueIdentifier);

            TargetView = targetView;
            ViewModelType = viewModelType;
            ViewModel = viewModel;

#if SL5
            Catel.Windows.FrameworkElementExtensions.FixUILanguageBug((System.Windows.FrameworkElement)TargetView);
#endif

            ViewModelBehavior = (viewModel != null) ? LogicViewModelBehavior.Injected : LogicViewModelBehavior.Dynamic;

            if (ViewModel != null)
            {
                SetDataContext(ViewModel);
            }

            // Very impoortant to exit here in design mode
            if (CatelEnvironment.IsInDesignMode)
            {
                return;
            }

            Log.Debug("Subscribing to view events");

            ViewLoadManager.AddView(this);
            this.SubscribeToWeakGenericEvent<ViewLoadEventArgs>(ViewLoadManager, "ViewLoading", OnViewLoadedManagerLoading);
            this.SubscribeToWeakGenericEvent<ViewLoadEventArgs>(ViewLoadManager, "ViewLoaded", OnViewLoadedManagerLoaded);
            this.SubscribeToWeakGenericEvent<ViewLoadEventArgs>(ViewLoadManager, "ViewUnloading", OnViewLoadedManagerUnloading);
            this.SubscribeToWeakGenericEvent<ViewLoadEventArgs>(ViewLoadManager, "ViewUnloaded", OnViewLoadedManagerUnloaded);

            // Required so the ViewLoadManager can handle the rest
            targetView.Loaded += (sender, e) => Loaded.SafeInvoke(this);
            targetView.Unloaded += (sender, e) => Unloaded.SafeInvoke(this);

            TargetView.DataContextChanged += OnTargetViewDataContextChanged;

            Log.Debug("Subscribing to view properties");

            // This also subscribes to DataContextChanged, don't double subscribe
            var viewPropertiesToSubscribe = DetermineInterestingViewProperties();
            foreach (var viewPropertyToSubscribe in viewPropertiesToSubscribe)
            {
                TargetView.SubscribeToPropertyChanged(viewPropertyToSubscribe, OnTargetViewPropertyChanged);
            }

            Log.Debug("Constructed behavior '{0}' for '{1}'", GetType().Name, TargetView.GetType().Name);
        }
开发者ID:justdude,项目名称:DbExport,代码行数:74,代码来源:LogicBase.cs


注:本文中的IView.SubscribeToPropertyChanged方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。