You can create the .NET MAUI Expander application with SfExpander using C#. Below is a simple example of how to implement this in your project. C# public partial class MainPage : ContentPage { StackLayout stack; SfExpander expander1, expander2; public MainPage() { InitializeComponent(); stack = new StackLayout(); // Expander 1 expander1 = new SfExpander(); // Expander header view var header1 = new Grid() { HeightRequest = 40 }; var headerLabel = new Label() { HorizontalTextAlignment = TextAlignment.Start, VerticalTextAlignment = TextAlignment.Center, Text = "Veg Pizza", }; header1.Children.Add(headerLabel); expander1.Header = header1; // Expander content view var content1 = new Grid() { HeightRequest = 60 }; var contentLabel = new Label() { HorizontalTextAlignment = TextAlignment.Start, VerticalTextAlignment = TextAlignment.Center, HeightRequest = 60, Text = "Veg pizza is prepared with the items that meet vegetarian standards by not including any meat or animal tissue products.", }; content1.Children.Add(contentLabel); expander1.Content = content1; // Expander 2 expander2 = new SfExpander(); // Expander header view var header2 = new Grid() { HeightRequest = 40 }; var headerLabel2 = new Label() { Text = "Non- Veg Pizza", HorizontalTextAlignment = TextAlignment.Start, VerticalTextAlignment = TextAlignment.Center, }; header2.Children.Add(headerLabel2); expander2!.Header = header2; // Expander content view var content2 = new Grid() { HeightRequest = 60 }; var contentLabel2 = new Label() { HeightRequest = 60, Text = "Non-veg pizza is prepared by including the meat and animal tissue products.", VerticalTextAlignment = TextAlignment.Center, HorizontalTextAlignment = TextAlignment.Start, }; content2.Children.Add(contentLabel2); expander2!.Content = content2; stack.Children.Add(expander1); stack.Children.Add(expander2); this.Content = stack; } } Download the complete sample on GitHub Conclusion I hope you have enjoyed learning how to work with .NET MAUI Expander using C#. You can refer to our .NET MAUI Expander feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started with configuration specifications. Check out our components from the License and Downloads page for current customers. If you are new to Syncfusion®, try our 30-day free trial to check out our other controls. Please let us know in the comments section if you have any queries or require clarification. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!
You can create the SfExpander using the C# in Xamarin.Forms. C# Creating the SfExpander in the constructor of the MainPage. public partial class MainPage : ContentPage { SfExpander expander, expander2; ScrollView scrollView; StackLayout stack; public MainPage() { InitializeComponent(); scrollView = new ScrollView(); stack = new StackLayout(); //Expander One expander = new SfExpander(); //Expander Header var headergrid = new Grid() { HeightRequest =60 }; var headerLabel = new Label() { TextColor = Color.White, BackgroundColor = Color.Teal, HorizontalTextAlignment =TextAlignment.Center , Text = "Veg Pizza", VerticalTextAlignment = TextAlignment.Center }; headergrid.Children.Add(headerLabel); expander.Header = headergrid; //Expander Content var contentgrid = new Grid() { HeightRequest =60 }; var contentLabel = new Label() { TextColor = Color.Black, BackgroundColor = Color.White, Text = "Veg pizza is prepared with the items that meet vegetarian standards by not including any meat or animal tissue products.", VerticalTextAlignment = TextAlignment.Center, HeightRequest = 50 }; contentgrid.Children.Add(contentLabel); expander.Content = contentgrid; //Expander Two expander2 = new SfExpander(); //Expander Header var headergrid2 = new Grid() { HeightRequest =60 }; var headerLabel2 = new Label() { TextColor = Color.White, BackgroundColor = Color.Teal, Text = "Non- Veg Pizza", HorizontalTextAlignment = TextAlignment.Center, VerticalTextAlignment = TextAlignment.Center }; headergrid2.Children.Add(headerLabel2); expander2.Header = headergrid2; //Expander Content var contentgrid2 = new Grid(); var contentLabel2 = new Label() { TextColor = Color.Black, BackgroundColor = Color.White, Text = "Non-veg pizza is prepared by including the meat and animal tissue products.", VerticalTextAlignment = TextAlignment.Center, HeightRequest = 50 }; contentgrid2.Children.Add(contentLabel2); expander2.Content = contentgrid2; stack.Children.Add(expander); stack.Children.Add(expander2); scrollView.Content = stack; this.Content = scrollView; } } View sample in GitHub