Articles in this section
Category / Section

How to center align the header text in .NET MAUI Expander (SfExpander)?

3 mins read

You can center align the text of the Expander Header in .NET MAUI Expander using the custom header view as shown in the code snippet below.

XAML:

Set HorizontalTextAlignment and VerticalTextAlignment of the header label to Center.

<ScrollView BackgroundColor="#EDF2F5" Padding="0,30,0,0">
    <StackLayout>
        <syncfusion:SfExpander>
            <syncfusion:SfExpander.Header>
                <Grid HeightRequest="50">
                    <Label Text="Veg Pizza" TextColor="#495F6E" VerticalTextAlignment="Center" HorizontalTextAlignment="Center"/>
                </Grid>
            </syncfusion:SfExpander.Header>
            <syncfusion:SfExpander.Content>
                <Grid Padding="10,10,10,10" BackgroundColor="#FFFFFF">
                    <Label BackgroundColor="#FFFFFF" HeightRequest="60" Text="Veg pizza is prepared with the items that meet vegetarian standards by not including any meat or animal tissue products." TextColor="#303030" VerticalTextAlignment="Center"/>
                </Grid>
            </syncfusion:SfExpander.Content>
        </syncfusion:SfExpander>

        <syncfusion:SfExpander>
            <syncfusion:SfExpander.Header>
                <Grid HeightRequest="50">
                    <Label Text="Non-veg Pizza" TextColor="#495F6E" VerticalTextAlignment="Center" HorizontalTextAlignment="Center"/>
                </Grid>
            </syncfusion:SfExpander.Header>
            <syncfusion:SfExpander.Content>
                <Grid Padding="10,10,10,10" BackgroundColor="#FFFFFF">
                    <Label Text="Non-veg pizza is prepared by including the meat and animal tissue products." HeightRequest="50" TextColor="#303030" VerticalTextAlignment="Center"/>
                </Grid>
            </syncfusion:SfExpander.Content>
        </syncfusion:SfExpander>
    </StackLayout>
</ScrollView>

Output:

ExpanderHeader.png

Download the complete sample on GitHub

Conclusion:

I hope you enjoyed learning how to center-align the Expander header text in .NET MAUI Expander.

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!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied