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


C# ViewModelBase类代码示例

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


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

示例1: PublicRoomsPage

        public PublicRoomsPage(ViewModelBase viewModel)
            : base(viewModel)
        {
            var listView = new BindableListView
                {
                    ItemTemplate = new DataTemplate(() =>
                        {
                        var textCell = new TextCell();
                            textCell.SetBinding(TextCell.TextProperty, new Binding("Name"));
                            textCell.TextColor = Styling.BlackText;
                            //textCell.SetBinding(TextCell.DetailProperty, new Binding("Description"));
                            return textCell;
                        }),
                    SeparatorVisibility = SeparatorVisibility.None
                };

            listView.SetBinding(ListView.ItemsSourceProperty, new Binding("PublicRooms"));
            listView.SetBinding(BindableListView.ItemClickedCommandProperty, new Binding("SelectRoomCommand"));

            var loadingIndicator = new ActivityIndicator ();
            loadingIndicator.SetBinding(ActivityIndicator.IsRunningProperty, new Binding("IsBusy"));
            loadingIndicator.SetBinding(ActivityIndicator.IsVisibleProperty, new Binding("IsBusy"));

            Content = new StackLayout
            {
                Children =
                        {
                            loadingIndicator,
                            listView
                        }
            };
        }
开发者ID:alexnaraghi,项目名称:SharedSquawk,代码行数:32,代码来源:PublicRoomsPage.cs

示例2: CreateWindow

        Window CreateWindow(ViewModelBase viewModel)
        {
            Type windowType;
            lock (_viewMap)
            {
                if (!_viewMap.ContainsKey(viewModel.GetType()))
                    throw new ArgumentException("viewModel not registered");
                windowType = _viewMap[viewModel.GetType()];
            }

            var window = (Window)Activator.CreateInstance(windowType);
            window.DataContext = viewModel;
            window.Closed += OnClosed;

            lock (_openedWindows)
            {
                // Last window opened is considered the 'owner' of the window.
                // May not be 100% correct in some situations but it is more
                // then good enough for handling dialog windows
                if (_openedWindows.Count > 0)
                {
                    Window lastOpened = _openedWindows[_openedWindows.Count - 1];

                    if (window != lastOpened)
                        window.Owner = lastOpened;
                }

                _openedWindows.Add(window);
            }

            // Listen for the close event
            Messenger.Default.Register<RequestCloseMessage>(window, viewModel, OnRequestClose);

            return window;
        }
开发者ID:notsonormal,项目名称:AstoundingDock,代码行数:35,代码来源:ViewService.cs

示例3: ShowViewModel

        public bool ShowViewModel(string title, ViewModelBase viewModel)
        {
            var win = new DialogWindow(viewModel) {Title = title};
            win.ShowDialog();

            return win.CloseResult;
        }
开发者ID:fitims,项目名称:RX-MVVM,代码行数:7,代码来源:DialogService.cs

示例4: EquipmentRightViewModel

        public EquipmentRightViewModel(ViewModelBase parent)
        {
            Parent = parent;

            Label11 = "Asset ID:";
            Label21 = "Fed Form:";
            Label12 = "Equipment Type:";
            Label22 = "Rated Voltage:";
            Label13 = "Location:";
            Label23 = "Problem?:";

            Equipment equipment = ((EquipmentViewModel)Parent).SelectedEquipment;

            TextBox11 = equipment.Asset_ID;
            //TextBox21 = equipment.f;
            TextBox12 = equipment.EquipmentTypeID.ToString();
            //TextBox22 = equipment;
            TextBox13 = equipment.LocationID.ToString();
            //TextBox23 = equipment;

            SetTab1Page();
            SetTab2Page();
            SetTab3Page();
            SetTab4Page();
            SetTab5Page();
            SetTab6Page();
            SetTab7Page();
            SetTab8Page();
        }
开发者ID:pdsoft,项目名称:SAL.WPF,代码行数:29,代码来源:EquipmentRightViewModel.cs

示例5: Next

        public static async Task<ViewModelBase> Next(LinkViewModel parentLink, ViewModelBase currentActual)
        {
            if (parentLink != null)
            {
                var viewModelContextService = ServiceLocator.Current.GetInstance<IViewModelContextService>();
                var firstRedditViewModel = viewModelContextService.ContextStack.FirstOrDefault(context => context is RedditViewModel) as RedditViewModel;
                if (firstRedditViewModel != null)
                {
                    RepositionContextScroll(parentLink);

                    var imagesService = ServiceLocator.Current.GetInstance<IImagesService>();
                    var offlineService = ServiceLocator.Current.GetInstance<IOfflineService>();
                    var settingsService = ServiceLocator.Current.GetInstance<ISettingsService>();
                    ViewModelBase stackNext = null;
                    if (settingsService.OnlyFlipViewUnread && (stackNext = LinkHistory.Forward()) != null)
                    {
                        return stackNext;
                    }
                    else
                    {
                        var currentLinkPos = firstRedditViewModel.Links.IndexOf(parentLink);
                        var linksEnumerator = new NeverEndingRedditView(firstRedditViewModel, currentLinkPos, true);
                        var result = await MakeContextedTuple(imagesService, offlineService, settingsService, linksEnumerator);
                        LinkHistory.Push(currentActual);
                        return result;
                    }
                }
            }
            return null;
        }
开发者ID:Synergex,项目名称:Baconography,代码行数:30,代码来源:StreamViewUtility.cs

示例6: MapViewModel

        PivotItem MapViewModel(ViewModelBase viewModel)
        {
            var rvm = viewModel as RedditViewModel;

            var plainHeader = rvm.Heading == "The front page of this device" ? "front page" : rvm.Heading.ToLower();
            return new PivotItem { DataContext = viewModel, Header = rvm.IsTemporary ? "*" + plainHeader : plainHeader };
        }
开发者ID:Synergex,项目名称:Baconography,代码行数:7,代码来源:ReifiedSubredditTemplateCollectionConverter.cs

示例7: GotoReplyToPost

        public void GotoReplyToPost(ViewModelBase currentContext, CommentsViewModel source)
        {

			source.CurrentlyFocused = source.AddReplyComment(null);
			Messenger.Default.Send<FocusChangedMessage>(new FocusChangedMessage(source));
			
        }
开发者ID:hippiehunter,项目名称:Baconography,代码行数:7,代码来源:CommandDispatcher.cs

示例8: CheckForRatingsPromptAsync

        /// <summary>
        /// Executes business logic to determine if an instance of the application should prompt the user to solicit user ratings.
        /// If it determines it should, the dialog to solicit ratings will be displayed.
        /// </summary>
        /// <returns>Awaitable task is returned.</returns>
        public async Task CheckForRatingsPromptAsync(ViewModelBase vm)
        {
            bool showPrompt = false;

            // PLACE YOUR CUSTOM RATE PROMPT LOGIC HERE!
            this.LastPromptedForRating = Platform.Current.Storage.LoadSetting<DateTime>(LAST_PROMPTED_FOR_RATING);

            // If trial, not expired, and less than 2 days away from expiring, set as TRUE
            bool preTrialExpiredBasedPrompt = 
                Platform.Current.AppInfo.IsTrial 
                && !Platform.Current.AppInfo.IsTrialExpired 
                && DateTime.Now.AddDays(2) > Platform.Current.AppInfo.TrialExpirationDate;

            if (preTrialExpiredBasedPrompt && this.LastPromptedForRating == DateTime.MinValue)
            {
                showPrompt = true;
            }
            else if (this.LastPromptedForRating != DateTime.MinValue && this.LastPromptedForRating.AddDays(21) < DateTime.Now)
            {
                // Every X days after the last prompt, set as TRUE
                showPrompt = true;
            }
            else if(this.LastPromptedForRating == DateTime.MinValue && Windows.ApplicationModel.Package.Current.InstalledDate.DateTime.AddDays(3) < DateTime.Now)
            {
                // First time prompt X days after initial install
                showPrompt = true;
            }

            if(showPrompt)
                await this.PromptForRatingAsync(vm);
        }
开发者ID:Microsoft,项目名称:TVHelpers,代码行数:36,代码来源:RatingsManager.cs

示例9: PageNavigationMessage

 public PageNavigationMessage(ViewModelBase bindingViewModel, NavigationKind kind)
 {
     this.BindingViewModel = bindingViewModel;
     if (kind == NavigationKind.Navigate)
         throw new ArgumentException("Navigate は Pageを含むコンストラクタが必要です。");
     this.Kind = kind;
 }
开发者ID:karno,项目名称:Lycanthrope,代码行数:7,代码来源:PageNavigationMessage.cs

示例10: MvvmableContentPage

 public MvvmableContentPage(ViewModelBase viewModel)
 {
     _viewModel = viewModel;
     BindingContext = viewModel;
     Title = "SharedSquawk";
     BackgroundColor = Styling.BackgroundColor;
 }
开发者ID:alexnaraghi,项目名称:SharedSquawk,代码行数:7,代码来源:MvvmableContentPage.cs

示例11: WebViewBridge

        public WebViewBridge(IWebView webView, ViewModelBase viewModel)
        {
            _webView = webView;
            _bridge = new Bridge(viewModel, this);

            _webView.NativeViewInitialized += (sender, args) => _webView.DocumentReady += (sender2, args2) => Initialize();
        }
开发者ID:BaamStudios,项目名称:SharpAngie,代码行数:7,代码来源:WebViewBridge.cs

示例12: ProvideView

        public static void ProvideView(ViewModelBase vm, ViewModelBase parentVm = null)
        {
            IViewMap map = Maps.SingleOrDefault(x => x.ViewModelType == vm.GetType());

            if (map == null)
                return;

            var viewInstance = Activator.CreateInstance(map.ViewType) as Window;

            if (viewInstance == null)
                throw new InvalidOperationException(string.Format("Can not create an instance of {0}", map.ViewType));

            if (parentVm != null)
            {
                ViewInstance parent = RegisteredViews.SingleOrDefault(x => x.ViewModel == parentVm);

                if (parent != null)
                {
                    Window parentView = parent.View;

                    if (Application.Current.Windows.OfType<Window>().Any(x => Equals(x, parentView)))
                        viewInstance.Owner = parentView;
                }
            }

            viewInstance.DataContext = vm;

            RegisteredViews.Add(new ViewInstance(viewInstance, vm));

            viewInstance.Show();
        }
开发者ID:Scrivener07,项目名称:moddingSuite,代码行数:31,代码来源:DialogProvider.cs

示例13: Show

        public bool Show(ViewModelBase viewModel, int windowHeight = 600, int windowWidth = 860)
        {
            if(_window == null)
                _window = new WindowView();

            var refreashable = viewModel as IRefreashable;
            if (refreashable != null)
                refreashable.Refreash();

            if (_window.DataContext != null && _window.DataContext.Equals(viewModel))
            {
                return false;
            }

            if(_window.IsVisible)
            {
                _window.Focus();
                return false;
            }

            _window.Height = windowHeight;
            _window.Width = windowWidth;
            _window.Title = viewModel.ToString();
            _window.DataContext = viewModel;

            var result = _window.ShowDialog();

            _window = null;

            return result == true;
        }
开发者ID:dineshkummarc,项目名称:TimeManager,代码行数:31,代码来源:TrayWindow.cs

示例14: ApplyTo

        public void ApplyTo(ViewModelBase viewModel)
        {
            var dynamicObject = new DynamicObject(viewModel);

            var commands = dynamicObject.GetProperties().Where(p => p.PropertyType == typeof (DelegateCommand));

            foreach (var c in commands)
            {
                var command = c;
                var executeMethodName = string.Format("On{0}", command.Name);
                var canExecuteMethodName = string.Format("Can{0}", command.Name);

                var delegateCommand = command.GetValue(viewModel, null) as DelegateCommand;

                if (delegateCommand != null)
                {
                    if (dynamicObject.MethodExist(executeMethodName))
                    {
                        delegateCommand.ExecuteDelegate = () =>
                        {
                            dynamicObject.InvokeMethod(executeMethodName);
                        };
                    }

                    if (dynamicObject.MethodExist(canExecuteMethodName))
                    {
                        delegateCommand.CanExecuteDelegate = () =>
                        {
                            return (bool)dynamicObject.InvokeMethod(canExecuteMethodName);
                        };
                    }
                }
            }
        }
开发者ID:aklefdal,项目名称:TinyMVVM,代码行数:34,代码来源:BindCommandsDelegatesToMethods.cs

示例15: RegisterViewModel

		/// <summary>
		/// Initializes the view model and registers events so that the OnLoaded and OnUnloaded methods are called. 
		/// This method must be called in the constructor after the <see cref="InitializeComponent"/> method call. 
		/// </summary>
		/// <param name="viewModel">The view model. </param>
		/// <param name="view">The view. </param>
		public static void RegisterViewModel(ViewModelBase viewModel, FrameworkElement view)
		{
			viewModel.Initialize();

			view.Loaded += (sender, args) => viewModel.CallOnLoaded();
			view.Unloaded += (sender, args) => viewModel.CallOnUnloaded();
		}
开发者ID:zhangz,项目名称:Toolbox,代码行数:13,代码来源:ViewModelHelper.cs


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