Exemple #1
0
        public SettingsViewPageViewModel(INavigationService navigationService, IPageDialogService pageDlg)
        {
            InputText = new ReactiveProperty <string>().SetValidateAttribute(() => this.InputText);

            InputError = InputText.ObserveErrorChanged
                         .Select(x => x?.Cast <string>()?.FirstOrDefault())
                         .ToReadOnlyReactiveProperty();

            SectionToggleCommand = InputText.ObserveHasErrors.Select(x => !x).ToAsyncReactiveCommand();
            SectionToggleCommand.Subscribe(async _ => {
                InputSectionVisible.Value = !InputSectionVisible.Value;
                await Task.Delay(250);
            });

            ToProfileCommand.Subscribe(async _ => {
                await navigationService.NavigateAsync("DummyPage");
            });

            foreach (var item in languages)
            {
                ItemsSource.Add(new Person()
                {
                    Name = item,
                    Age  = 1
                });
            }

            SelectedItems.Add(ItemsSource[1]);
            SelectedItems.Add(ItemsSource[2]);
            SelectedItems.Add(ItemsSource[3]);
        }
        public CustomFontTestViewModel(INavigationService navigationService)
        {
            InputText = new ReactiveProperty <string>().SetValidateAttribute(() => this.InputText);

            InputError = InputText.ObserveErrorChanged
                         .Select(x => x?.Cast <string>()?.FirstOrDefault())
                         .ToReadOnlyReactiveProperty();

            SectionToggleCommand = InputText.ObserveHasErrors.Select(x => !x).ToAsyncReactiveCommand();
            SectionToggleCommand.Subscribe(async _ => {
                InputSectionVisible.Value = !InputSectionVisible.Value;
                await Task.Delay(250);
            });

            ToProfileCommand.Subscribe(async _ => {
                await navigationService.NavigateAsync("DummyPage");
            });

            foreach (var item in languages)
            {
                ItemsSource.Add(new Person()
                {
                    Name = item,
                    Age  = 1
                });
            }

            SelectedItems.Add(ItemsSource[1]);
            SelectedItems.Add(ItemsSource[2]);
            SelectedItems.Add(ItemsSource[3]);

            IsHeaderFont.Subscribe(o => {
                HeaderFont.Value = o ? "Anzu" : null;
            });

            IsFooterFont.Subscribe(o => {
                FooterFont.Value = o ? "Anzu" : null;
            });

            IsParentTitle.Subscribe(o => {
                ParentTitle.Value = o ? "Anzu" : null;
            });

            IsParentValue.Subscribe(o => {
                ParentValue.Value = o ? "Anzu" : null;
            });

            IsParentDesc.Subscribe(o => {
                ParentDesc.Value = o ? "Anzu" : null;
            });

            IsParentHint.Subscribe(o => {
                ParentHint.Value = o ? "Anzu" : null;
            });

            IsTitle.Subscribe(o => {
                Title.Value = o ? "" : null;
            });
            IsValue.Subscribe(o => {
                Value.Value = o ? "" : null;
            });
            IsDesc.Subscribe(o => {
                Desc.Value = o ? "" : null;
            });
            IsHint.Subscribe(o => {
                Hint.Value = o ? "" : null;
            });

            IsParentBold.Merge(IsParentItalic).Subscribe(o => {
                if (IsParentBold.Value && IsParentItalic.Value)
                {
                    ParentAttr.Value = FontAttributes.Bold | FontAttributes.Italic;
                }
                else if (IsParentBold.Value)
                {
                    ParentAttr.Value = FontAttributes.Bold;
                }
                else if (IsParentItalic.Value)
                {
                    ParentAttr.Value = FontAttributes.Italic;
                }
                else
                {
                    ParentAttr.Value = FontAttributes.None;
                }
            });

            IsBold.Merge(IsItalic).Subscribe(o => {
                if (IsBold.Value && IsItalic.Value)
                {
                    ChildAttr.Value = FontAttributes.Bold | FontAttributes.Italic;
                }
                else if (IsBold.Value)
                {
                    ChildAttr.Value = FontAttributes.Bold;
                }
                else if (IsItalic.Value)
                {
                    ChildAttr.Value = FontAttributes.Italic;
                }
                else
                {
                    ChildAttr.Value = FontAttributes.None;
                }
            });
        }