Beispiel #1
0
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            _textBox         = GetTemplateChild("TextBox") as TextBox;
            _popup           = GetTemplateChild("SuggestionsPopup") as Popup;
            _layoutRoot      = GetTemplateChild("LayoutRoot") as Grid;
            _suggestionsList = GetTemplateChild("SuggestionsList") as ListView;
            _queryButton     = GetTemplateChild("QueryButton") as Button;

#if __ANDROID__
            _popup.DisableFocus();
#endif

            UpdateQueryButton();
            UpdateTextBox();

            _textBoxBinding = new BindingPath("Text", null)
            {
                DataContext = _textBox, ValueChangedListener = this
            };

            Loaded   += (s, e) => RegisterEvents();
            Unloaded += (s, e) => UnregisterEvents();

            if (IsLoaded)
            {
                RegisterEvents();
            }
        }
Beispiel #2
0
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            _textBox         = GetTemplateChild("TextBox") as TextBox;
            _popup           = GetTemplateChild("SuggestionsPopup") as Popup;
            _layoutRoot      = GetTemplateChild("LayoutRoot") as Grid;
            _suggestionsList = GetTemplateChild("SuggestionsList") as ListView;
            _queryButton     = GetTemplateChild("QueryButton") as Button;

            // Uno specific: If the user enabled the legacy behavior for popup light dismiss default
            // we force it to false explicitly to make sure the AutoSuggestBox works correctly.
            if (FeatureConfiguration.Popup.EnableLightDismissByDefault)
            {
                _popup.IsLightDismissEnabled = false;
            }

#if __ANDROID__
            _popup.DisableFocus();
#endif

            UpdateQueryButton();
            UpdateTextBox();
            UpdateDescriptionVisibility(true);

            _textBoxBinding = new BindingPath("Text", null)
            {
                DataContext = _textBox, ValueChangedListener = this
            };

            Loaded   += (s, e) => RegisterEvents();
            Unloaded += (s, e) => UnregisterEvents();

            if (IsLoaded)
            {
                RegisterEvents();
            }
        }
Beispiel #3
0
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            _textBox         = GetTemplateChild("TextBox") as TextBox;
            _popup           = GetTemplateChild("SuggestionsPopup") as Popup;
            _layoutRoot      = GetTemplateChild("LayoutRoot") as Grid;
            _suggestionsList = GetTemplateChild("SuggestionsList") as ListView;
            _queryButton     = GetTemplateChild("QueryButton") as Button;

#if __ANDROID__
            _popup.DisableFocus();
#endif

            if (_queryButton != null)
            {
                _queryButton.Content = new SymbolIcon(Symbol.Find);
            }

            _textBox?.SetBinding(
                TextBox.TextProperty,
                new Binding()
            {
                Path                = "Text",
                RelativeSource      = RelativeSource.TemplatedParent,
                UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged,
                Mode                = BindingMode.TwoWay
            }
                );

            Loaded   += (s, e) => RegisterEvents();
            Unloaded += (s, e) => UnregisterEvents();

            if (IsLoaded)
            {
                RegisterEvents();
            }
        }