Articles in this section

How to Restrict Orientation Change from Sample Level in .NET MAUI SfGrid?

In this article, we will show you how to restrict the orientation changes from the sample level for Android and iOS platforms in the .NET MAUI DataGrid.

Android Platform
The code below demonstrates how to restrict orientation changes at the sample level on the Android platform. The following code needs to be added to the MainActivity.cs file located under Platforms -> Android -> MainActivity.cs.

public class MainActivity : MauiAppCompatActivity
{
    protected override void OnCreate(Bundle? savedInstanceState)
    {
        base.OnCreate(savedInstanceState);

        RequestedOrientation = ScreenOrientation.Portrait;
    }
}

Output

AndroidDemo.gif

iOS Platform
For iOS, you can define the allowed orientations in the Info.plist. You can find the Info.plist file located under platform -> iOS -> Info.plist.

Output

DeviceOrientaionIOS.png

Download the complete sample from GitHub.

Conclusion

I hope you enjoyed learning how to restrict orientation change from the sample level in .NET MAUI DataGrid.

You can refer to our .NET MAUI DataGrid feature tour page to learn about its other groundbreaking feature representations. Explore our .NET MAUI DataGrid Documentation to understand how to present and manipulate data.

For current customers, check out our .NET MAUI components on the License and Downloads page. If you are new to Syncfusion®, try our 30-day free trial to explore our .NET MAUI DataGrid and other .NET MAUI components.

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, or the 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)
Access denied
Access denied