コード例 #1
0
        public iOSSearchBarPageCS()
        {
            Xamarin.Forms.SearchBar searchBar = new Xamarin.Forms.SearchBar {
                Placeholder = "Enter search term"
            };
            searchBar.On <iOS>().SetSearchBarStyle(UISearchBarStyle.Minimal);

            Button styleButton = new Button {
                Text = "Toggle SearchBar Style"
            };

            styleButton.Clicked += (s, e) =>
            {
                switch (searchBar.On <iOS>().GetSearchBarStyle())
                {
                case UISearchBarStyle.Default:
                    searchBar.On <iOS>().SetSearchBarStyle(UISearchBarStyle.Minimal);
                    break;

                case UISearchBarStyle.Minimal:
                    searchBar.On <iOS>().SetSearchBarStyle(UISearchBarStyle.Prominent);
                    break;

                case UISearchBarStyle.Prominent:
                    searchBar.On <iOS>().SetSearchBarStyle(UISearchBarStyle.Default);
                    break;
                }
            };

            Button backgroundButton = new Button {
                Text = "Toggle Background"
            };

            backgroundButton.Clicked += (s, e) => searchBar.BackgroundColor = (searchBar.BackgroundColor == Color.Teal) ? Color.Default : Color.Teal;

            Title   = "SearchBar Style";
            Content = new StackLayout
            {
                Children =
                {
                    searchBar,
                    styleButton,
                    backgroundButton
                }
            };
        }
コード例 #2
0
        public WindowsSearchBarPageCS()
        {
            var searchBar = new Xamarin.Forms.SearchBar {
                Text = "Enter search term here"
            };

            searchBar.On <Windows>().SetIsSpellCheckEnabled(true);

            var toggleButton = new Button {
                Text = "Toggle spell check"
            };

            toggleButton.Clicked += (sender, e) =>
            {
                searchBar.On <Windows>().SetIsSpellCheckEnabled(!searchBar.On <Windows>().GetIsSpellCheckEnabled());
            };

            Title   = "SearchBar Spell Check";
            Content = new StackLayout
            {
                Margin   = new Thickness(20),
                Children = { searchBar, toggleButton }
            };
        }