Esempio n. 1
0
        public CreateDialogView()
        {
            InitializeComponent();

            AnimationContext = LayoutRoot;

            _createChatButton.Click += (sender, args) => ViewModel.Create();

            Loaded += (sender, args) =>
            {
                if (!_once)
                {
                    _once = true;

                    _searchBox = SelectedUsers.FindChildOfType <TextBox>();

                    if (_searchBox != null)
                    {
                        var keyPressEvents = Observable.FromEventPattern <TextChangedEventHandler, TextChangedEventArgs>(
                            keh => { _searchBox.TextChanged += keh; },
                            keh => { _searchBox.TextChanged -= keh; });

                        _keyPressSubscription = keyPressEvents
                                                .Throttle(TimeSpan.FromSeconds(0.1))
                                                .ObserveOnDispatcher()
                                                .Subscribe(e =>
                        {
                            SearchItems.Visibility = string.IsNullOrEmpty(_searchBox.Text.Trim()) ? Visibility.Collapsed : Visibility.Visible;

                            ViewModel.Search(_searchBox.Text);
                        });
                    }

                    BuildLocalizedAppBar();
                }

                ViewModel.ScrollTo += OnViewModelScrollTo;
            };
            Unloaded += (sender, args) =>
            {
                ViewModel.ScrollTo -= OnViewModelScrollTo;
            };
        }