Пример #1
0
        protected override void Init()
        {
            var searchBarWithSpellCheckLabel = new Label {
                Text = "SearchBar with SpellCheck Enabled:"
            };

            _searchBarWithSpellCheck = new SearchBar();
            _searchBarWithSpellCheck.On <WindowsOS>().SetIsSpellCheckEnabled(true);

            var searchBarWithoutSpellCheckLabel = new Label {
                Text = "SearchBar with SpellCheck Disabled:"
            };

            _searchBarWithoutSpellCheck = new SearchBar();
            _searchBarWithoutSpellCheck.On <WindowsOS>().SetIsSpellCheckEnabled(false);

            var searchBarToggleSpellCheck = new Label {
                Text = "SearchBar with Toggled SpellCheck:"
            };

            _searchBarToggleSpellCheck = new SearchBar();

            _toggleSpellCheckButton = new Button {
                Text = "Enable SpellCheck"
            };
            _toggleSpellCheckButton.Clicked += (object sender, EventArgs e) =>
            {
                if (_searchBarToggleSpellCheck.On <WindowsOS>().IsSpellCheckEnabled())
                {
                    _searchBarToggleSpellCheck.On <WindowsOS>().DisableSpellCheck();
                    _toggleSpellCheckButton.Text = "Enable SpellCheck";
                }
                else
                {
                    _searchBarToggleSpellCheck.On <WindowsOS>().EnableSpellCheck();
                    _toggleSpellCheckButton.Text = "Disable SpellCheck";
                }
            };

            Content = new StackLayout
            {
                Children =
                {
                    searchBarWithSpellCheckLabel,
                    _searchBarWithSpellCheck,
                    searchBarWithoutSpellCheckLabel,
                    _searchBarWithoutSpellCheck,
                    searchBarToggleSpellCheck,
                    _searchBarToggleSpellCheck,
                    _toggleSpellCheckButton
                }
            };
        }
Пример #2
0
        public SearchBariOS()
        {
            var prominent = new SearchBar {
                Placeholder = "Prominent"
            };

            prominent.On <iOS>().SetSearchBarStyle(UISearchBarStyle.Prominent);

            var minimal = new SearchBar {
                Placeholder = "Minimal"
            };

            minimal.On <iOS>().SetSearchBarStyle(UISearchBarStyle.Minimal);

            var prominentBackground = new SearchBar {
                Placeholder = "Prominent on colored background"
            };

            prominentBackground.On <iOS>().SetSearchBarStyle(UISearchBarStyle.Prominent);

            var minimalBackground = new SearchBar {
                Placeholder = "Minimal on colored background"
            };

            minimalBackground.On <iOS>().SetSearchBarStyle(UISearchBarStyle.Minimal);

            Content = new StackLayout
            {
                Children =
                {
                    prominent,
                    minimal,
                    new StackLayout()
                    {
                        BackgroundColor = Color.Red,
                        Children        =
                        {
                            prominentBackground,
                            minimalBackground
                        }
                    }
                }
            };
        }