public HorizontalStackLayoutGallery() { var layout = new HorizontalStackLayout(); for (int n = 0; n < 3; n++) { layout.Add(new Label { Text = $"Label {n} in a horizontal stack" }); } Content = layout; }
void SetupMauiLayout() { const string loremIpsum = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. " + "Quisque ut dolor metus. Duis vel iaculis mauris, sit amet finibus mi. " + "Etiam congue ornare risus, in facilisis libero tempor eget. " + "Phasellus mattis mollis libero ut semper. In sit amet sapien odio. " + "Sed interdum ullamcorper dui eu rutrum. Vestibulum non sagittis justo. " + "Cras rutrum scelerisque elit, et porta est lobortis ac. " + "Pellentesque eu ornare tortor. Sed bibendum a nisl at laoreet."; var verticalStack = new VerticalStackLayout() { Spacing = 5, BackgroundColor = Color.AntiqueWhite }; var horizontalStack = new HorizontalStackLayout() { Spacing = 2, BackgroundColor = Color.CornflowerBlue }; verticalStack.Add(CreateSampleGrid()); verticalStack.Add(new Label { Text = " ", Padding = new Thickness(10) }); var label = new Label { Text = "End-aligned text", BackgroundColor = Color.Fuchsia, HorizontalTextAlignment = TextAlignment.End }; label.Margin = new Thickness(15, 10, 20, 15); verticalStack.Add(label); verticalStack.Add(new Label { Text = "This should be BIG text!", FontSize = 24, HorizontalOptions = LayoutOptions.End }); verticalStack.Add(new Label { Text = "This should be BOLD text!", FontAttributes = FontAttributes.Bold, HorizontalOptions = LayoutOptions.Center }); verticalStack.Add(new Label { Text = "This should be a CUSTOM font!", FontFamily = "Dokdo" }); verticalStack.Add(new Label { Text = "This should have padding", Padding = new Thickness(40), BackgroundColor = Color.LightBlue }); verticalStack.Add(new Label { Text = loremIpsum }); verticalStack.Add(new Label { Text = loremIpsum, MaxLines = 2 }); verticalStack.Add(new Label { Text = loremIpsum, LineBreakMode = LineBreakMode.TailTruncation }); verticalStack.Add(new Label { Text = loremIpsum, MaxLines = 2, LineBreakMode = LineBreakMode.TailTruncation }); verticalStack.Add(new Label { Text = "This should have five times the line height!", LineHeight = 5 }); var visibleClearButtonEntry = new Entry() { ClearButtonVisibility = ClearButtonVisibility.WhileEditing, Placeholder = "This Entry will show clear button if has input." }; var hiddenClearButtonEntry = new Entry() { ClearButtonVisibility = ClearButtonVisibility.Never, Placeholder = "This Entry will not..." }; verticalStack.Add(visibleClearButtonEntry); verticalStack.Add(hiddenClearButtonEntry); verticalStack.Add(new Editor { Placeholder = "This is an editor placeholder." }); var paddingButton = new Button { Padding = new Thickness(40), Text = "This button has a padding!!", BackgroundColor = Color.Purple, }; verticalStack.Add(paddingButton); var underlineLabel = new Label { Text = "underline", TextDecorations = TextDecorations.Underline }; verticalStack.Add(underlineLabel); verticalStack.Add(new ActivityIndicator()); verticalStack.Add(new ActivityIndicator { Color = Color.Red, IsRunning = true }); var button = new Button() { Text = _viewModel.Text, WidthRequest = 200 }; var button2 = new Button() { TextColor = Color.Green, Text = "Hello I'm a button", BackgroundColor = Color.Purple, Margin = new Thickness(12) }; horizontalStack.Add(button); horizontalStack.Add(button2); horizontalStack.Add(new Label { Text = "And these buttons are in a HorizontalStackLayout", VerticalOptions = LayoutOptions.Center }); verticalStack.Add(horizontalStack); verticalStack.Add(new CheckBox()); verticalStack.Add(new CheckBox { BackgroundColor = Color.LightPink }); verticalStack.Add(new CheckBox { IsChecked = true, Color = Color.Aquamarine }); verticalStack.Add(new DatePicker()); verticalStack.Add(new Editor()); verticalStack.Add(new Editor { Text = "Editor" }); verticalStack.Add(new Editor { Text = "Lorem ipsum dolor sit amet", MaxLength = 10 }); verticalStack.Add(new Editor { Text = "Predictive Text Off", IsTextPredictionEnabled = false }); verticalStack.Add(new Editor { Text = "Lorem ipsum dolor sit amet", FontSize = 10, FontFamily = "dokdo_regular" }); verticalStack.Add(new Editor { Text = "ReadOnly Editor", IsReadOnly = true }); var entry = new Entry(); entry.TextChanged += (sender, e) => { Debug.WriteLine($"Text Changed from '{e.OldTextValue}' to '{e.NewTextValue}'"); }; verticalStack.Add(entry); verticalStack.Add(new Entry { Text = "Entry", TextColor = Color.DarkRed, FontFamily = "Dokdo" }); verticalStack.Add(new Entry { IsPassword = true, TextColor = Color.Black }); verticalStack.Add(new Entry { IsTextPredictionEnabled = false }); verticalStack.Add(new Entry { Placeholder = "This should be placeholder text" }); verticalStack.Add(new Entry { Text = "This should be read only property", IsReadOnly = true }); verticalStack.Add(new Entry { MaxLength = 5, Placeholder = "MaxLength text" }); verticalStack.Add(new Entry { Text = "This should be text with character spacing", CharacterSpacing = 10 }); verticalStack.Add(new ProgressBar { Progress = 0.5 }); verticalStack.Add(new ProgressBar { Progress = 0.5, BackgroundColor = Color.LightCoral }); verticalStack.Add(new ProgressBar { Progress = 0.5, ProgressColor = Color.Purple }); var searchBar = new SearchBar(); searchBar.CharacterSpacing = 4; searchBar.Text = "A search query"; verticalStack.Add(searchBar); var placeholderSearchBar = new SearchBar(); placeholderSearchBar.Placeholder = "Placeholder"; verticalStack.Add(placeholderSearchBar); var monkeyList = new List <string> { "Baboon", "Capuchin Monkey", "Blue Monkey", "Squirrel Monkey", "Golden Lion Tamarin", "Howler Monkey", "Japanese Macaque" }; var picker = new Picker { Title = "Select a monkey" }; picker.ItemsSource = monkeyList; verticalStack.Add(picker); verticalStack.Add(new Slider()); verticalStack.Add(new Stepper()); verticalStack.Add(new Stepper { BackgroundColor = Color.IndianRed }); verticalStack.Add(new Stepper { Minimum = 0, Maximum = 10, Value = 5 }); verticalStack.Add(new Switch()); verticalStack.Add(new Switch() { OnColor = Color.Green }); verticalStack.Add(new Switch() { ThumbColor = Color.Yellow }); verticalStack.Add(new Switch() { OnColor = Color.Green, ThumbColor = Color.Yellow }); verticalStack.Add(new DatePicker()); verticalStack.Add(new TimePicker()); verticalStack.Add(new TimePicker { Time = TimeSpan.FromHours(8), CharacterSpacing = 6 }); verticalStack.Add(new Image() { Source = "dotnet_bot.png" }); Content = new ScrollView { Content = verticalStack }; }
public TapGestureGalleryPage() { TapCommand = new Command <Color>(HandleTapCommand); var vertical = new VerticalStackLayout { VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.Center, Spacing = 40 }; var horizontal = new HorizontalStackLayout { Spacing = 20, HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center }; vertical.Add(horizontal); var singleTapLabel = new Label { Text = "Tap me!", BackgroundColor = Colors.PaleGreen }; var singleTapGesture = new TapGestureRecognizer { Command = TapCommand, CommandParameter = Colors.PaleGreen, NumberOfTapsRequired = 1, }; singleTapLabel.GestureRecognizers.Add(singleTapGesture); horizontal.Add(singleTapLabel); var doubleTapLabel = new Label { Text = "Double Tap me!!", BackgroundColor = Colors.Aqua }; var doubleTapGesture = new TapGestureRecognizer { Command = TapCommand, CommandParameter = Colors.Aqua, NumberOfTapsRequired = 2, }; doubleTapLabel.GestureRecognizers.Add(doubleTapGesture); horizontal.Add(doubleTapLabel); changeColorBoxView = new Label { VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.Center, WidthRequest = 200, HeightRequest = 50, Text = "Tap Gesture Gallery" }; vertical.Add(changeColorBoxView); vertical.Add(new Button() { Text = "Toggle Single Tap Gesture", Command = new Command(() => { if (singleTapLabel.GestureRecognizers.Count > 0) { singleTapLabel.GestureRecognizers.RemoveAt(0); } else { singleTapLabel.GestureRecognizers.Add(singleTapGesture); } }) }); Content = vertical; }
void SetupMauiLayout() { var verticalStack = new VerticalStackLayout() { Spacing = 5, BackgroundColor = Colors.AntiqueWhite }; var horizontalStack = new HorizontalStackLayout() { Spacing = 2, BackgroundColor = Colors.CornflowerBlue }; verticalStack.Add(CreateSampleGrid()); verticalStack.Add(CreateResizingButton()); AddTextResizeDemo(verticalStack); verticalStack.Add(new Label { Text = " ", Padding = new Thickness(10) }); var label = new Label { Text = "End-aligned text", BackgroundColor = Colors.Fuchsia, HorizontalTextAlignment = TextAlignment.End }; label.Margin = new Thickness(15, 10, 20, 15); SemanticProperties.SetHint(label, "Hint Text"); SemanticProperties.SetDescription(label, "Description Text"); verticalStack.Add(label); verticalStack.Add(new Label { Text = "This should be BIG text!", FontSize = 24, HorizontalOptions = LayoutOptions.End }); SemanticProperties.SetHeadingLevel((BindableObject)verticalStack.Children.Last(), SemanticHeadingLevel.Level1); verticalStack.Add(new Label { Text = "This should be BOLD text!", FontAttributes = FontAttributes.Bold, HorizontalOptions = LayoutOptions.Center }); verticalStack.Add(new Label { Text = "This should have character spacing!", CharacterSpacing = 3 }); verticalStack.Add(new Label { Text = "This should be a CUSTOM font!", FontFamily = "Dokdo" }); verticalStack.Add( new Button { Text = "Push a Page", Command = new Command(async() => { await Navigation.PushAsync(new SemanticsPage()); }) } ); verticalStack.Add(new Label { Text = "This should have padding", Padding = new Thickness(40), BackgroundColor = Colors.LightBlue }); verticalStack.Add(new Label { Text = loremIpsum }); verticalStack.Add(new Label { Text = loremIpsum, MaxLines = 2 }); verticalStack.Add(new Label { Text = loremIpsum, LineBreakMode = LineBreakMode.TailTruncation }); verticalStack.Add(new Label { Text = loremIpsum, MaxLines = 2, LineBreakMode = LineBreakMode.TailTruncation }); verticalStack.Add(new Label { Text = "This should have five times the line height! " + loremIpsum, LineHeight = 5, MaxLines = 2 }); SemanticProperties.SetHeadingLevel((BindableObject)verticalStack.Children.Last(), SemanticHeadingLevel.Level2); var visibleClearButtonEntry = new Entry() { ClearButtonVisibility = ClearButtonVisibility.WhileEditing, Placeholder = "This Entry will show clear button if has input." }; var hiddenClearButtonEntry = new Entry() { ClearButtonVisibility = ClearButtonVisibility.Never, Placeholder = "This Entry will not..." }; verticalStack.Add(visibleClearButtonEntry); verticalStack.Add(hiddenClearButtonEntry); verticalStack.Add(new Editor { Placeholder = "This is an editor placeholder." }); verticalStack.Add(new Editor { Placeholder = "Green Text Color.", TextColor = Colors.Green }); var paddingButton = new Button { Padding = new Thickness(40), Text = "This button has a padding!!", BackgroundColor = Colors.Purple, }; verticalStack.Add(paddingButton); var underlineLabel = new Label { Text = "underline", TextDecorations = TextDecorations.Underline }; verticalStack.Add(underlineLabel); verticalStack.Add(new ActivityIndicator()); verticalStack.Add(new ActivityIndicator { Color = Colors.Red, IsRunning = true }); var button = new Button() { Text = _viewModel.Text, WidthRequest = 200 }; button.Clicked += async(sender, e) => { var events = _services.GetRequiredService <ILifecycleEventService>(); events.InvokeEvents <Action <string> >("CustomEventName", action => action("VALUE")); var location = await Geolocation.GetLocationAsync(new GeolocationRequest(GeolocationAccuracy.Lowest)); Debug.WriteLine($"I tracked you down to {location.Latitude}, {location.Longitude}! You can't hide!"); }; var button2 = new Button() { TextColor = Colors.Green, Text = "Hello I'm a button", // BackgroundColor = Color.Purple, Margin = new Thickness(12) }; horizontalStack.Add(button); horizontalStack.Add(button2); horizontalStack.Add(new Label { Text = "And these buttons are in a HorizontalStackLayout", VerticalOptions = LayoutOptions.Center }); verticalStack.Add(horizontalStack); verticalStack.Add(new Button { Text = "CharacterSpacing" }); verticalStack.Add(new Button { CharacterSpacing = 8, Text = "CharacterSpacing" }); var checkbox = new CheckBox(); checkbox.CheckedChanged += (sender, e) => { Debug.WriteLine($"Checked Changed to '{e.Value}'"); }; verticalStack.Add(checkbox); verticalStack.Add(new CheckBox { BackgroundColor = Colors.LightPink }); verticalStack.Add(new CheckBox { IsChecked = true, Color = Colors.Aquamarine }); verticalStack.Add(new Editor()); verticalStack.Add(new Editor { Text = "Editor" }); verticalStack.Add(new Editor { Text = "Lorem ipsum dolor sit amet", MaxLength = 10 }); verticalStack.Add(new Editor { Text = "Predictive Text Off", IsTextPredictionEnabled = false }); verticalStack.Add(new Editor { Text = "Lorem ipsum dolor sit amet", FontSize = 10, FontFamily = "dokdo_regular" }); verticalStack.Add(new Editor { Text = "ReadOnly Editor", IsReadOnly = true }); var entry = new Entry(); entry.TextChanged += (sender, e) => { Debug.WriteLine($"Text Changed from '{e.OldTextValue}' to '{e.NewTextValue}'"); }; var entryMargin = new Thickness(10, 0); verticalStack.Add(entry); verticalStack.Add(new Entry { Text = "Entry", TextColor = Colors.DarkRed, FontFamily = "Dokdo", MaxLength = -1, Margin = entryMargin }); verticalStack.Add(new Entry { IsPassword = true, TextColor = Colors.Black, Placeholder = "Pasword Entry", Margin = entryMargin }); verticalStack.Add(new Entry { IsTextPredictionEnabled = false }); verticalStack.Add(new Entry { Placeholder = "This should be placeholder text", Margin = entryMargin }); verticalStack.Add(new Entry { Text = "This should be read only property", IsReadOnly = true, Margin = entryMargin }); verticalStack.Add(new Entry { MaxLength = 5, Placeholder = "MaxLength text", Margin = entryMargin }); verticalStack.Add(new Entry { Text = "This should be text with character spacing", CharacterSpacing = 10 }); verticalStack.Add(new Entry { Keyboard = Keyboard.Numeric, Placeholder = "Numeric Entry" }); verticalStack.Add(new Entry { Keyboard = Keyboard.Email, Placeholder = "Email Entry" }); verticalStack.Add(new ProgressBar { Progress = 0.5 }); verticalStack.Add(new ProgressBar { Progress = 0.5, BackgroundColor = Colors.LightCoral }); verticalStack.Add(new ProgressBar { Progress = 0.5, ProgressColor = Colors.Purple }); var searchBar = new SearchBar(); searchBar.CharacterSpacing = 4; searchBar.Text = "A search query"; verticalStack.Add(searchBar); var placeholderSearchBar = new SearchBar(); placeholderSearchBar.Placeholder = "Placeholder"; verticalStack.Add(placeholderSearchBar); var monkeyList = new List <string> { "Baboon", "Capuchin Monkey", "Blue Monkey", "Squirrel Monkey", "Golden Lion Tamarin", "Howler Monkey", "Japanese Macaque" }; var picker = new Picker { Title = "Select a monkey", FontFamily = "Dokdo", HorizontalTextAlignment = TextAlignment.Center }; picker.ItemsSource = monkeyList; verticalStack.Add(picker); verticalStack.Add(new Slider()); verticalStack.Add(new Stepper()); verticalStack.Add(new Stepper { BackgroundColor = Colors.IndianRed }); verticalStack.Add(new Stepper { Minimum = 0, Maximum = 10, Value = 5 }); verticalStack.Add(new Switch()); verticalStack.Add(new Switch() { OnColor = Colors.Green }); verticalStack.Add(new Switch() { ThumbColor = Colors.Yellow }); verticalStack.Add(new Switch() { OnColor = Colors.Green, ThumbColor = Colors.Yellow }); verticalStack.Add(new DatePicker()); verticalStack.Add(new DatePicker { CharacterSpacing = 6 }); verticalStack.Add(new DatePicker { FontSize = 24 }); verticalStack.Add(new TimePicker()); verticalStack.Add(new TimePicker { Time = TimeSpan.FromHours(8), CharacterSpacing = 6 }); verticalStack.Add(new Label { Text = "IMAGES (static | animated):" }); verticalStack.Add(CreateImagesGrid()); Content = new ScrollView { Content = verticalStack }; }
void SetupMauiLayout() { const string loremIpsum = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. " + "Quisque ut dolor metus. Duis vel iaculis mauris, sit amet finibus mi. " + "Etiam congue ornare risus, in facilisis libero tempor eget. " + "Phasellus mattis mollis libero ut semper. In sit amet sapien odio. " + "Sed interdum ullamcorper dui eu rutrum. Vestibulum non sagittis justo. " + "Cras rutrum scelerisque elit, et porta est lobortis ac. " + "Pellentesque eu ornare tortor. Sed bibendum a nisl at laoreet."; var verticalStack = new VerticalStackLayout() { Spacing = 5, BackgroundColor = Colors.AntiqueWhite }; var horizontalStack = new HorizontalStackLayout() { Spacing = 2, BackgroundColor = Colors.CornflowerBlue }; verticalStack.Add(CreateSampleGrid()); verticalStack.Add(new Label { Text = " ", Padding = new Thickness(10) }); var label = new Label { Text = "End-aligned text", BackgroundColor = Colors.Fuchsia, HorizontalTextAlignment = TextAlignment.End }; label.Margin = new Thickness(15, 10, 20, 15); SemanticProperties.SetHint(label, "Hint Text"); SemanticProperties.SetDescription(label, "Description Text"); verticalStack.Add(label); verticalStack.Add(new Label { Text = "This should be BIG text!", FontSize = 24, HorizontalOptions = LayoutOptions.End }); SemanticProperties.SetHeadingLevel((BindableObject)verticalStack.Children.Last(), SemanticHeadingLevel.Level1); verticalStack.Add(new Label { Text = "This should be BOLD text!", FontAttributes = FontAttributes.Bold, HorizontalOptions = LayoutOptions.Center }); verticalStack.Add(new Label { Text = "This should be a CUSTOM font!", FontFamily = "Dokdo" }); #if __ANDROID__ string fontFamily = "ionicons.ttf#"; #elif WINDOWS string fontFamily = "Assets/ionicons.ttf#ionicons"; #else string fontFamily = "Ionicons"; #endif verticalStack.Add(new Image { Source = new FontImageSource() { FontFamily = fontFamily, Glyph = '\uf2fe'.ToString() } }); verticalStack.Add(new Label { Text = "This should have padding", Padding = new Thickness(40), BackgroundColor = Colors.LightBlue }); verticalStack.Add(new Label { Text = loremIpsum }); verticalStack.Add(new Label { Text = loremIpsum, MaxLines = 2 }); verticalStack.Add(new Label { Text = loremIpsum, LineBreakMode = LineBreakMode.TailTruncation }); verticalStack.Add(new Label { Text = loremIpsum, MaxLines = 2, LineBreakMode = LineBreakMode.TailTruncation }); verticalStack.Add(new Label { Text = "This should have five times the line height! " + loremIpsum, LineHeight = 5, MaxLines = 2 }); SemanticProperties.SetHeadingLevel((BindableObject)verticalStack.Children.Last(), SemanticHeadingLevel.Level2); var visibleClearButtonEntry = new Entry() { ClearButtonVisibility = ClearButtonVisibility.WhileEditing, Placeholder = "This Entry will show clear button if has input." }; var hiddenClearButtonEntry = new Entry() { ClearButtonVisibility = ClearButtonVisibility.Never, Placeholder = "This Entry will not..." }; verticalStack.Add(visibleClearButtonEntry); verticalStack.Add(hiddenClearButtonEntry); verticalStack.Add(new Editor { Placeholder = "This is an editor placeholder." }); verticalStack.Add(new Editor { Placeholder = "Green Text Color.", TextColor = Colors.Green }); var paddingButton = new Button { Padding = new Thickness(40), Text = "This button has a padding!!", BackgroundColor = Colors.Purple, }; verticalStack.Add(paddingButton); var underlineLabel = new Label { Text = "underline", TextDecorations = TextDecorations.Underline }; verticalStack.Add(underlineLabel); verticalStack.Add(new ActivityIndicator()); verticalStack.Add(new ActivityIndicator { Color = Colors.Red, IsRunning = true }); var button = new Button() { Text = _viewModel.Text, WidthRequest = 200 }; button.Clicked += async(sender, e) => { var events = _services.GetRequiredService <ILifecycleEventService>(); events.InvokeEvents <Action <string> >("CustomEventName", action => action("VALUE")); var location = await Geolocation.GetLocationAsync(new GeolocationRequest(GeolocationAccuracy.Lowest)); Debug.WriteLine($"I tracked you down to {location.Latitude}, {location.Longitude}! You can't hide!"); }; var button2 = new Button() { TextColor = Colors.Green, Text = "Hello I'm a button", BackgroundColor = Colors.Purple, Margin = new Thickness(12) }; horizontalStack.Add(button); horizontalStack.Add(button2); horizontalStack.Add(new Label { Text = "And these buttons are in a HorizontalStackLayout", VerticalOptions = LayoutOptions.Center }); verticalStack.Add(horizontalStack); verticalStack.Add(new Button { Text = "CharacterSpacing" }); verticalStack.Add(new Button { CharacterSpacing = 8, Text = "CharacterSpacing" }); var checkbox = new CheckBox(); checkbox.CheckedChanged += (sender, e) => { Debug.WriteLine($"Checked Changed to '{e.Value}'"); }; verticalStack.Add(checkbox); verticalStack.Add(new CheckBox { BackgroundColor = Colors.LightPink }); verticalStack.Add(new CheckBox { IsChecked = true, Color = Colors.Aquamarine }); verticalStack.Add(new Editor()); verticalStack.Add(new Editor { Text = "Editor" }); verticalStack.Add(new Editor { Text = "Lorem ipsum dolor sit amet", MaxLength = 10 }); verticalStack.Add(new Editor { Text = "Predictive Text Off", IsTextPredictionEnabled = false }); verticalStack.Add(new Editor { Text = "Lorem ipsum dolor sit amet", FontSize = 10, FontFamily = "dokdo_regular" }); verticalStack.Add(new Editor { Text = "ReadOnly Editor", IsReadOnly = true }); var entry = new Entry(); entry.TextChanged += (sender, e) => { Debug.WriteLine($"Text Changed from '{e.OldTextValue}' to '{e.NewTextValue}'"); }; verticalStack.Add(entry); verticalStack.Add(new Entry { Text = "Entry", TextColor = Colors.DarkRed, FontFamily = "Dokdo", MaxLength = -1 }); verticalStack.Add(new Entry { IsPassword = true, TextColor = Colors.Black, Placeholder = "Pasword Entry" }); verticalStack.Add(new Entry { IsTextPredictionEnabled = false }); verticalStack.Add(new Entry { Placeholder = "This should be placeholder text" }); verticalStack.Add(new Entry { Text = "This should be read only property", IsReadOnly = true }); verticalStack.Add(new Entry { MaxLength = 5, Placeholder = "MaxLength text" }); verticalStack.Add(new Entry { Text = "This should be text with character spacing", CharacterSpacing = 10 }); verticalStack.Add(new Entry { Keyboard = Keyboard.Numeric, Placeholder = "Numeric Entry" }); verticalStack.Add(new Entry { Keyboard = Keyboard.Email, Placeholder = "Email Entry" }); verticalStack.Add(new ProgressBar { Progress = 0.5 }); verticalStack.Add(new ProgressBar { Progress = 0.5, BackgroundColor = Colors.LightCoral }); verticalStack.Add(new ProgressBar { Progress = 0.5, ProgressColor = Colors.Purple }); var searchBar = new SearchBar(); searchBar.CharacterSpacing = 4; searchBar.Text = "A search query"; verticalStack.Add(searchBar); var placeholderSearchBar = new SearchBar(); placeholderSearchBar.Placeholder = "Placeholder"; verticalStack.Add(placeholderSearchBar); var monkeyList = new List <string> { "Baboon", "Capuchin Monkey", "Blue Monkey", "Squirrel Monkey", "Golden Lion Tamarin", "Howler Monkey", "Japanese Macaque" }; var picker = new Picker { Title = "Select a monkey", FontFamily = "Dokdo" }; picker.ItemsSource = monkeyList; verticalStack.Add(picker); verticalStack.Add(new Slider()); verticalStack.Add(new Stepper()); verticalStack.Add(new Stepper { BackgroundColor = Colors.IndianRed }); verticalStack.Add(new Stepper { Minimum = 0, Maximum = 10, Value = 5 }); verticalStack.Add(new Switch()); verticalStack.Add(new Switch() { OnColor = Colors.Green }); verticalStack.Add(new Switch() { ThumbColor = Colors.Yellow }); verticalStack.Add(new Switch() { OnColor = Colors.Green, ThumbColor = Colors.Yellow }); verticalStack.Add(new DatePicker()); verticalStack.Add(new DatePicker { CharacterSpacing = 6 }); verticalStack.Add(new DatePicker { FontSize = 24 }); verticalStack.Add(new TimePicker()); verticalStack.Add(new TimePicker { Time = TimeSpan.FromHours(8), CharacterSpacing = 6 }); verticalStack.Add(new Image() { Source = "dotnet_bot.png" }); Content = new ScrollView { Content = verticalStack }; }
void SetupMauiLayout() { var verticalStack = new VerticalStackLayout() { Spacing = 5, BackgroundColor = Color.AntiqueWhite }; var horizontalStack = new HorizontalStackLayout() { Spacing = 2, BackgroundColor = Color.CornflowerBlue }; var label = new Label { Text = "This will disappear in ~5 seconds", BackgroundColor = Color.Fuchsia }; label.Margin = new Thickness(15, 10, 20, 15); verticalStack.Add(label); verticalStack.Add(new Label { Text = "This should be BIG text!", FontSize = 24 }); verticalStack.Add(new Label { Text = "This should be BOLD text!", FontAttributes = FontAttributes.Bold }); verticalStack.Add(new Label { Text = "This should be a CUSTOM font!", FontFamily = "Dokdo" }); verticalStack.Add(new Label { Text = "This should have padding", Padding = new Thickness(40), BackgroundColor = Color.LightBlue }); var button = new Button() { Text = _viewModel.Text, WidthRequest = 200 }; var button2 = new Button() { TextColor = Color.Green, Text = "Hello I'm a button", BackgroundColor = Color.Purple, Margin = new Thickness(12) }; horizontalStack.Add(button); horizontalStack.Add(button2); horizontalStack.Add(new Label { Text = "And these buttons are in a HorizontalStackLayout" }); verticalStack.Add(horizontalStack); var entry = new Entry(); entry.TextChanged += (sender, e) => { System.Console.WriteLine($"Text Changed from '{e.OldTextValue}' to '{e.NewTextValue}'"); }; verticalStack.Add(entry); verticalStack.Add(new Entry { Text = "Entry", TextColor = Color.DarkRed }); verticalStack.Add(new Entry { IsPassword = true, TextColor = Color.Black }); verticalStack.Add(new Entry { IsTextPredictionEnabled = false }); verticalStack.Add(new Entry { Placeholder = "This should be placeholder text" }); verticalStack.Add(new Entry { Text = "This should be read only property", IsReadOnly = true }); verticalStack.Add(new Slider()); verticalStack.Add(new Switch()); verticalStack.Add(new Switch() { OnColor = Color.Green }); verticalStack.Add(new Switch() { ThumbColor = Color.Yellow }); verticalStack.Add(new Switch() { OnColor = Color.Green, ThumbColor = Color.Yellow }); verticalStack.Add(new DatePicker()); verticalStack.Add(new TimePicker()); verticalStack.Add(new Image() { Source = "dotnet_bot.png" }); Content = verticalStack; }
void SetupMauiLayout() { var verticalStack = new VerticalStackLayout() { Spacing = 5, BackgroundColor = Color.AntiqueWhite }; var horizontalStack = new HorizontalStackLayout() { Spacing = 2, BackgroundColor = Color.CornflowerBlue }; var label = new Label { Text = "This will disappear in ~5 seconds", BackgroundColor = Color.Fuchsia }; label.Margin = new Thickness(15, 10, 20, 15); verticalStack.Add(label); verticalStack.Add(new Label { Text = "This should be BIG text!", FontSize = 24 }); verticalStack.Add(new Label { Text = "This should be BOLD text!", FontAttributes = FontAttributes.Bold }); verticalStack.Add(new Label { Text = "This should be a CUSTOM font!", FontFamily = "Dokdo" }); verticalStack.Add(new Label { Text = "This should have padding", Padding = new Thickness(40), BackgroundColor = Color.LightBlue }); var button = new Button() { Text = _viewModel.Text, WidthRequest = 200 }; var button2 = new Button() { TextColor = Color.Green, Text = "Hello I'm a button", BackgroundColor = Color.Purple, Margin = new Thickness(12) }; horizontalStack.Add(button); horizontalStack.Add(button2); horizontalStack.Add(new Label { Text = "And these buttons are in a HorizontalStackLayout" }); verticalStack.Add(horizontalStack); verticalStack.Add(new Entry()); verticalStack.Add(new Entry { Text = "Entry", TextColor = Color.DarkRed }); verticalStack.Add(new Entry { IsPassword = true, TextColor = Color.Black }); verticalStack.Add(new Entry { IsTextPredictionEnabled = false }); verticalStack.Add(new Slider()); verticalStack.Add(new Switch()); verticalStack.Add(new Switch() { OnColor = Color.Green }); verticalStack.Add(new Switch() { ThumbColor = Color.Yellow }); verticalStack.Add(new Switch() { OnColor = Color.Green, ThumbColor = Color.Yellow }); verticalStack.Add(new DatePicker()); verticalStack.Add(new TimePicker()); verticalStack.Add(new Image() { Source = "https://github.com/dotnet/maui/blob/main/src/ControlGallery/src/Xamarin.Forms.ControlGallery.Android/Resources/drawable/FlowerBuds.jpg?raw=true" }); Content = verticalStack; }
void SetupMauiLayout() { const string loremIpsum = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. " + "Quisque ut dolor metus. Duis vel iaculis mauris, sit amet finibus mi. " + "Etiam congue ornare risus, in facilisis libero tempor eget. " + "Phasellus mattis mollis libero ut semper. In sit amet sapien odio. " + "Sed interdum ullamcorper dui eu rutrum. Vestibulum non sagittis justo. " + "Cras rutrum scelerisque elit, et porta est lobortis ac. " + "Pellentesque eu ornare tortor. Sed bibendum a nisl at laoreet."; var verticalStack = new VerticalStackLayout() { Spacing = 5, BackgroundColor = Color.AntiqueWhite }; var horizontalStack = new HorizontalStackLayout() { Spacing = 2, BackgroundColor = Color.CornflowerBlue }; verticalStack.Add(new Label { Text = " ", Padding = new Thickness(10) }); var label = new Label { Text = "centered text", BackgroundColor = Color.Fuchsia, HorizontalTextAlignment = TextAlignment.End }; label.Margin = new Thickness(15, 10, 20, 15); verticalStack.Add(label); verticalStack.Add(new Label { Text = "This should be BIG text!", FontSize = 24 }); verticalStack.Add(new Label { Text = "This should be BOLD text!", FontAttributes = FontAttributes.Bold }); verticalStack.Add(new Label { Text = "This should be a CUSTOM font!", FontFamily = "Dokdo" }); verticalStack.Add(new Label { Text = "This should have padding", Padding = new Thickness(40), BackgroundColor = Color.LightBlue }); verticalStack.Add(new Label { Text = loremIpsum }); verticalStack.Add(new Label { Text = loremIpsum, MaxLines = 2 }); verticalStack.Add(new Label { Text = loremIpsum, LineBreakMode = LineBreakMode.TailTruncation }); verticalStack.Add(new Label { Text = loremIpsum, MaxLines = 2, LineBreakMode = LineBreakMode.TailTruncation }); var paddingButton = new Button { Padding = new Thickness(40), Text = "This button has a padding!!", BackgroundColor = Color.Purple, }; verticalStack.Add(paddingButton); var underlineLabel = new Label { Text = "underline", TextDecorations = TextDecorations.Underline }; verticalStack.Add(underlineLabel); var button = new Button() { Text = _viewModel.Text, WidthRequest = 200 }; var button2 = new Button() { TextColor = Color.Green, Text = "Hello I'm a button", BackgroundColor = Color.Purple, Margin = new Thickness(12) }; horizontalStack.Add(button); horizontalStack.Add(button2); horizontalStack.Add(new Label { Text = "And these buttons are in a HorizontalStackLayout" }); verticalStack.Add(horizontalStack); verticalStack.Add(new Editor()); verticalStack.Add(new Editor { Text = "Editor" }); var entry = new Entry(); entry.TextChanged += (sender, e) => { System.Console.WriteLine($"Text Changed from '{e.OldTextValue}' to '{e.NewTextValue}'"); }; verticalStack.Add(entry); verticalStack.Add(new Entry { Text = "Entry", TextColor = Color.DarkRed }); verticalStack.Add(new Entry { IsPassword = true, TextColor = Color.Black }); verticalStack.Add(new Entry { IsTextPredictionEnabled = false }); verticalStack.Add(new Entry { Placeholder = "This should be placeholder text" }); verticalStack.Add(new Entry { Text = "This should be read only property", IsReadOnly = true }); verticalStack.Add(new ProgressBar { Progress = 0.5 }); verticalStack.Add(new ProgressBar { Progress = 0.5, BackgroundColor = Color.LightCoral }); verticalStack.Add(new ProgressBar { Progress = 0.5, ProgressColor = Color.Purple }); var searchBar = new SearchBar(); searchBar.Text = "A search query"; verticalStack.Add(searchBar); var placeholderSearchBar = new SearchBar(); placeholderSearchBar.Placeholder = "Placeholder"; verticalStack.Add(placeholderSearchBar); verticalStack.Add(new Slider()); verticalStack.Add(new Switch()); verticalStack.Add(new Switch() { OnColor = Color.Green }); verticalStack.Add(new Switch() { ThumbColor = Color.Yellow }); verticalStack.Add(new Switch() { OnColor = Color.Green, ThumbColor = Color.Yellow }); verticalStack.Add(new DatePicker()); verticalStack.Add(new TimePicker()); verticalStack.Add(new Image() { Source = "dotnet_bot.png" }); Content = verticalStack; }
void SetupMauiLayout() { var verticalStack = new VerticalStackLayout() { Spacing = 5, BackgroundColor = Color.AntiqueWhite }; var horizontalStack = new HorizontalStackLayout() { Spacing = 2, BackgroundColor = Color.CornflowerBlue }; var label = new Label { Text = "This will disappear in ~5 seconds", BackgroundColor = Color.Fuchsia }; label.Margin = new Thickness(15, 10, 20, 15); verticalStack.Add(label); verticalStack.Add(new Label { Text = "This should be BIG text!", FontSize = 24 }); verticalStack.Add(new Label { Text = "This should be BOLD text!", FontAttributes = FontAttributes.Bold }); verticalStack.Add(new Label { Text = "This should be a CUSTOM font!", FontFamily = "Dokdo" }); var button = new Button() { Text = _viewModel.Text, WidthRequest = 200 }; var button2 = new Button() { TextColor = Color.Green, Text = "Hello I'm a button", BackgroundColor = Color.Purple, Margin = new Thickness(12) }; horizontalStack.Add(button); horizontalStack.Add(button2); horizontalStack.Add(new Label { Text = "And these buttons are in a HorizontalStackLayout" }); verticalStack.Add(horizontalStack); verticalStack.Add(new Entry()); verticalStack.Add(new Entry { Text = "Entry", TextColor = Color.DarkRed }); verticalStack.Add(new Entry { IsPassword = true, TextColor = Color.Black }); verticalStack.Add(new Slider()); verticalStack.Add(new Switch()); verticalStack.Add(new Switch() { OnColor = Color.Green }); verticalStack.Add(new Switch() { ThumbColor = Color.Yellow }); verticalStack.Add(new Switch() { OnColor = Color.Green, ThumbColor = Color.Yellow }); Content = verticalStack; }