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


C# IViewModel类代码示例

本文整理汇总了C#中IViewModel的典型用法代码示例。如果您正苦于以下问题:C# IViewModel类的具体用法?C# IViewModel怎么用?C# IViewModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: ShowWindow

 public int ShowWindow(ViewModelType type, IViewModel viewModel)
 {
     KeyValuePair<int, Window> k = this.CreateWindow(type, viewModel);
     viewModel.WindowId = k.Key;
     k.Value.Show();
     return k.Key;
 }
开发者ID:KatrukSergii,项目名称:CallCenter,代码行数:7,代码来源:WindowService.cs

示例2: AsyncMethodWithViewModel

 private async void AsyncMethodWithViewModel(IAsyncOperation<bool> asyncOperation, bool result, IViewModel viewModel)
 {
     bool b = await asyncOperation;
     b.ShouldEqual(result);
     ViewModel = viewModel;
     AsyncMethodInvoked = true;
 }
开发者ID:MuffPotter,项目名称:MugenMvvmToolkit,代码行数:7,代码来源:SerializableAsyncOperationTest.cs

示例3: Export

        /// <summary>
        /// Exports the <paramref name="viewModel" />'s view to the print or clipboard or file.
        /// </summary>
        /// <param name="viewModel">The view model.</param>
        /// <param name="exportMode">The export mode.</param>
        /// <param name="dpiX">The dpi X.</param>
        /// <param name="dpiY">The dpi Y.</param>
        /// <exception cref="System.InvalidOperationException"></exception>
        /// <exception cref="System.ArgumentNullException">The <paramref name="viewModel" /> is <c>null</c>.</exception>
        /// <remarks>If <paramref name="exportMode" /> is <see cref="ExportMode.Print" /> then the <paramref name="dpiX" /> and <paramref name="dpiY" /> argument will be ignored.</remarks>
        public virtual void Export(IViewModel viewModel, ExportMode exportMode = ExportMode.Print, double dpiX = 96, double dpiY = 96)
        {
            Argument.IsNotNull(() => viewModel);

            var view = _viewManager.GetViewsOfViewModel(viewModel).OfType<UIElement>().FirstOrDefault();
            if (view == null)
            {
                string message = string.Format(CultureInfo.InvariantCulture, "There no an active view for this view model of type '{0}'", viewModel.GetType().FullName);

                Log.Error(message);

                throw new InvalidOperationException(message);
            }

            if (exportMode == ExportMode.Print)
            {
                Print(view);
            }
            else
            {
                var bitmap = CreateImageFromUIElement(view, dpiX, dpiY);
#if !SILVERLIGHT 
                if (exportMode == ExportMode.File)
                {
                    SaveToFile(bitmap);
                }
                else
                {
                    Clipboard.SetImage(bitmap);
                }
#else
                SaveToFile(bitmap);
#endif
            }
        }
开发者ID:JaysonJG,项目名称:Catel,代码行数:45,代码来源:ViewExportService.cs

示例4: CloseItem

 public void CloseItem(IViewModel parentViewModel)
 {
     DeactivateItem(parentViewModel, true);
     _activatedItems.Pop();
     if (_activatedItems.Any())
         base.ActivateItem(_activatedItems.Peek());
 }
开发者ID:karczewskip,项目名称:Waiter-Management-2,代码行数:7,代码来源:ParentViewModelBase.cs

示例5: TraceViewModel

 public static void TraceViewModel(AuditAction auditAction, IViewModel viewModel)
 {
     Action<AuditAction, IViewModel> handler = TraceViewModelHandler;
     if (handler != null)
         handler(auditAction, viewModel);
     ServiceProvider.Tracer.TraceViewModel(auditAction, viewModel);
 }
开发者ID:sami1971,项目名称:MugenMvvmToolkit,代码行数:7,代码来源:Tracer.cs

示例6: ReleaseViewModel

 public void ReleaseViewModel(IViewModel viewModel)
 {
     if (viewModel != null)
     {
         ReleaseViewModelInstance(viewModel);
     }
 }
开发者ID:Galad,项目名称:Hanno,代码行数:7,代码来源:DefaultViewModelFactory.cs

示例7: Export

        /// <summary>
        /// Exports the <paramref name="viewModel" />'s view to the print or clipboard or file.
        /// </summary>
        /// <param name="viewModel">The view model.</param>
        /// <param name="exportMode">The export mode.</param>
        /// <param name="dpiX">The dpi X.</param>
        /// <param name="dpiY">The dpi Y.</param>
        /// <exception cref="System.InvalidOperationException"></exception>
        /// <exception cref="System.ArgumentNullException">The <paramref name="viewModel" /> is <c>null</c>.</exception>
        /// <remarks>If <paramref name="exportMode" /> is <see cref="ExportMode.Print" /> then the <paramref name="dpiX" /> and <paramref name="dpiY" /> argument will be ignored.</remarks>
        public virtual void Export(IViewModel viewModel, ExportMode exportMode = ExportMode.Print, double dpiX = 96, double dpiY = 96)
        {
            Argument.IsNotNull("viewModel", viewModel);

            var view = _viewManager.GetViewsOfViewModel(viewModel).OfType<UIElement>().FirstOrDefault();
            if (view == null)
            {
                throw Log.ErrorAndCreateException < InvalidOperationException >("There no an active view for this view model of type '{0}'", viewModel.GetType().FullName);
            }

            var bitmap = CreateImageFromUIElement(view, dpiX, dpiY);

            if (exportMode == ExportMode.Print)
            {
                Print(bitmap);
            }
            else
            {
#if !SILVERLIGHT 
                if (exportMode == ExportMode.File)
                {
                    SaveToFile(bitmap);
                }
                else
                {
                    Clipboard.SetImage(bitmap);
                }
#else
                SaveToFile(bitmap);
#endif
            }
        }
开发者ID:Catel,项目名称:Catel,代码行数:42,代码来源:ViewExportService.cs

示例8: WindowLogic

        /// <summary>
        /// Initializes a new instance of the <see cref="WindowLogic"/> class.
        /// </summary>
        /// <param name="targetWindow">The window this provider should take care of.</param>
        /// <param name="viewModelType">Type of the view model.</param>
        /// <param name="viewModel">The view model to inject.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="targetWindow"/> is <c>null</c>.</exception>
        public WindowLogic(IView targetWindow, Type viewModelType = null, IViewModel viewModel = null)
            : base(targetWindow, viewModelType, viewModel)
        {
            var targetWindowType = targetWindow.GetType();

            string eventName;

            var closedEvent = targetWindowType.GetEventEx("Closed");
            if (closedEvent != null)
            {
                eventName = "Closed";

                _dynamicEventListener = new DynamicEventListener(targetWindow, "Closed", this, "OnTargetWindowClosed");
            }
            else
            {
                eventName = "Unloaded";

                _dynamicEventListener = new DynamicEventListener(targetWindow, "Unloaded", this, "OnTargetWindowClosed");
            }

            _targetWindowClosedEventName = eventName;

            Log.Debug("Using '{0}.{1}' event to determine window closing", targetWindowType.FullName, eventName);
        }
开发者ID:Catel,项目名称:Catel,代码行数:32,代码来源:WindowLogic.cs

示例9: OnPropertyChanging

 public override void OnPropertyChanging(IViewModel viewModel, string propertyName, object oldValue)
 {
     OnPropertyChangingCalled = true;
     OnPropertyChangingViewModel = viewModel;
     OnPropertyChangingPropertyName = propertyName;
     OnPropertyChangingOldValue = oldValue;
 }
开发者ID:matthijskoopman,项目名称:Catel,代码行数:7,代码来源:TestAuditor.cs

示例10: OnPropertyChanged

 public override void OnPropertyChanged(IViewModel viewModel, string propertyName, object newValue)
 {
     OnPropertyChangedCalled = true;
     OnPropertyChangedViewModel = viewModel;
     OnPropertyChangedPropertyName = propertyName;
     OnPropertyChangedNewValue = newValue;
 }
开发者ID:matthijskoopman,项目名称:Catel,代码行数:7,代码来源:TestAuditor.cs

示例11: SetContext

 public static EventHandler SetContext(IViewModel viewModel)
 {
     return (o,e) =>
            	{
            		(o as FrameworkElement).DataContext = viewModel;
            	};
 }
开发者ID:maxfridbe,项目名称:PicoMVVM,代码行数:7,代码来源:ViewResolverBase.cs

示例12: CreateWindow

        private KeyValuePair<int, Window> CreateWindow(ViewModelType type, IViewModel viewModel)
        {
            this.index++;
            Window window;

            switch (type)
            {
                case ViewModelType.LoginWindow:
                    window = new LoginWindow {DataContext = viewModel};
                    break;
                case ViewModelType.MainWindow:
                    window = new MainWindow {DataContext = viewModel};
                    break;
                case ViewModelType.SettingsWindow:
                    window = new SettignsWindow { DataContext = viewModel };
                    break;
                default:
                    window = new Window { DataContext = viewModel };
                    break;
            }

            window.DataContext = viewModel;

            KeyValuePair<int, Window> keyValuePair = new KeyValuePair<int, Window>(this.index, window);
            this.windows.Add(keyValuePair);
            return keyValuePair;
        }
开发者ID:KatrukSergii,项目名称:CallCenter,代码行数:27,代码来源:WindowService.cs

示例13: Create

        public BindingExpression Create(IViewModel viewModel, String elementId, String targetProperty, Binding binding)
        {
            var type = viewModel.GetType();

            // find property dic
            IDictionary<string, MemberInfo> propertyDic;
            if(!_typeBindingDic.TryGetValue(type, out propertyDic))
            {
                propertyDic = new Dictionary<string, MemberInfo>();
                _typeBindingDic[type] = propertyDic;
            }

            MemberInfo propertyInfo = null;

            if(!propertyDic.TryGetValue(targetProperty, out propertyInfo))
            {
                // find the member...
                propertyInfo = type.GetMember(targetProperty).FirstOrDefault();

                if(propertyInfo == null)
                {
                    return null;
                }
                propertyDic[targetProperty] = propertyInfo;
            }
            var bindingExpression = new BindingExpression(binding, propertyInfo, viewModel);

            return bindingExpression;
        }
开发者ID:rhwilburn,项目名称:MVVM-for-Mono,代码行数:29,代码来源:BindingFactory.cs

示例14: CongregatePresenter

 /// <summary>
 /// Initializes a new instance of the <see cref="CongregatePresenter"/> class.
 /// </summary>
 /// <param name="view">The view.</param>
 /// <param name="stockItemView">The stock item view.</param>
 /// <param name="bankAccountView">The bank account view.</param>
 /// <param name="model">The model.</param>
 public CongregatePresenter(ICongregateView view, IStockItemView stockItemView, IBankAccountView bankAccountView, IViewModel model)
 {
     this._View = view;
     this._StockItemView = stockItemView;
     this._BankAccountView = bankAccountView;
     this._Model = model as AppDataManager;
 }
开发者ID:bergmannf,项目名称:hw_spas10,代码行数:14,代码来源:CongregatePresenter.cs

示例15: MainView

 public MainView()
 {
     InitializeComponent();
     vm = DataContext as IViewModel;
     vm.OnActivate();
     tabControl.SelectionChanged += Items_CurrentChanged;
 }
开发者ID:noelex,项目名称:Cindeck,代码行数:7,代码来源:MainView.xaml.cs


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