We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to use SfDataGrid in Prism?

Platform: Xamarin.Forms |
Control: SfDataGrid |
Published Date: November 10, 2017 |
Last Revised Date: November 10, 2017

Prism helps us to implement collection of design patterns with well-structured and maintainable XAML applications, including MVVM, dependency injection, commands, Event Aggregator.

Prism MVVM helps to clean separation of concerns between the user interface and the model behind it. A major advantage of MVVM is data-binding to display information and respond to user input.

Installing and using the Prism Template Pack

Go to Tools > Extensions and Updates select Online and search for Prism Template Pack. Locate the extensions, click Download, and complete the installation. Click the Restart Now button.

Now that we have the Template Pack installed, lets create a new solution. Go to File > New > Project... select Installed > Templates > Visual C# > Prism. Here you will find all the templates available for a new Prism project/solution.

Select Prism Unity App (Forms) Visual C# fill in the name of your project/solution and click OK

Create SfDataGrid using Prism

Within the Portable project there is a Views folder. This folder will contain all your view related code.

Right click on the Views folder, click Add > New Item... under Installed > Visual C# > Prism > Forms select Prism Content Page (Forms)->your view page name and click Add. This creates a blank content page and equivalent ViewModel class in ViewModels folder.

You can define the SfDataGrid using the below code example:

XML/XAML

 

xmlns:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms" is prism namespace

We need to set prism:ViewModelLocator.AutowireViewModel as True to the view model (MainPageViewModel.csautomatically via naming conventions allowing for databinding to the view model.

Using the below code example, you can navigate the page to View page and register the classes using RegisterTypes override method.

C#

 

Sample link: How to load SfDataGrid using prism library?

 

2X faster development

The ultimate Xamarin UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon