Data Grid Control for .NET MAUI (Free plugin to Sort, Filter & Show Data)
October 04, 2023
Read MoreIn this video, we will see the recap of .NET MAUI articles post on 2023. Supercharge your .NET MAUI projects by referring this articles. ...
October 04, 2023
Read MoreIntroduction Supercharge your .NET MAUI projects with Devexpress Charts! This blog will explain you how to implement the chart in...
Supercharge your .NET MAUI projects with Devexpress Charts! This blog will explain you how to implement the chart in .NET MAUI projects using Dev express, a life time free plugin. This plugin has many customisations and will directly skip into the implementation part.
using DevExpress.Maui;
.UseDevExpress()
xmlns:dxc="clr-namespace:DevExpress.Maui.Charts;assembly=DevExpress.Maui.Charts"
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:dxc="clr-namespace:DevExpress.Maui.Charts;assembly=DevExpress.Maui.Charts"
x:Class="ScatterChartGetStarted.MainPage">
<dxc:ChartView/>
</ContentPage>
public class ViewModel {
public CountryGdp GdpValueForUSA { get; }
public CountryGdp GdpValueForChina { get; }
public CountryGdp GdpValueForJapan { get; }
public ViewModel() {
GdpValueForUSA = new CountryGdp(
"USA",
new GdpValue(new DateTime(2020, 1, 1), 20.93),
new GdpValue(new DateTime(2019, 1, 1), 21.43),
new GdpValue(new DateTime(2018, 1, 1), 20.58),
new GdpValue(new DateTime(2017, 1, 1), 19.391),
new GdpValue(new DateTime(2016, 1, 1), 18.624),
new GdpValue(new DateTime(2015, 1, 1), 18.121),
new GdpValue(new DateTime(2014, 1, 1), 17.428),
new GdpValue(new DateTime(2013, 1, 1), 16.692),
new GdpValue(new DateTime(2012, 1, 1), 16.155),
new GdpValue(new DateTime(2011, 1, 1), 15.518),
new GdpValue(new DateTime(2010, 1, 1), 14.964)
);
GdpValueForChina = new CountryGdp(
"China",
new GdpValue(new DateTime(2020, 1, 1), 14.72),
new GdpValue(new DateTime(2019, 1, 1), 14.34),
new GdpValue(new DateTime(2018, 1, 1), 13.89),
new GdpValue(new DateTime(2017, 1, 1), 12.238),
new GdpValue(new DateTime(2016, 1, 1), 11.191),
new GdpValue(new DateTime(2015, 1, 1), 11.065),
new GdpValue(new DateTime(2014, 1, 1), 10.482),
new GdpValue(new DateTime(2013, 1, 1), 9.607),
new GdpValue(new DateTime(2012, 1, 1), 8.561),
new GdpValue(new DateTime(2011, 1, 1), 7.573),
new GdpValue(new DateTime(2010, 1, 1), 6.101)
);
GdpValueForJapan = new CountryGdp(
"Japan",
new GdpValue(new DateTime(2020, 1, 1), 4.888),
new GdpValue(new DateTime(2019, 1, 1), 5.082),
new GdpValue(new DateTime(2018, 1, 1), 4.955),
new GdpValue(new DateTime(2017, 1, 1), 4.872),
new GdpValue(new DateTime(2016, 1, 1), 4.949),
new GdpValue(new DateTime(2015, 1, 1), 4.395),
new GdpValue(new DateTime(2014, 1, 1), 4.850),
new GdpValue(new DateTime(2013, 1, 1), 5.156),
new GdpValue(new DateTime(2012, 1, 1), 6.203),
new GdpValue(new DateTime(2011, 1, 1), 6.156),
new GdpValue(new DateTime(2010, 1, 1), 5.700)
);
}
}
public class CountryGdp {
public string CountryName { get; }
public IList<GdpValue> Values { get; }
public CountryGdp(string country, params GdpValue[] values) {
this.CountryName = country;
this.Values = new List<GdpValue>(values);
}
}
public class GdpValue {
public DateTime Year { get; }
public double Value { get; }
public GdpValue(DateTime year, double value) {
this.Year = year;
this.Value = value;
}
}
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:dxc="clr-namespace:DevExpress.Maui.Charts;assembly=DevExpress.Maui.Charts"
xmlns:ios="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific;assembly=Microsoft.Maui.Controls"
ios:Page.UseSafeArea="True"
xmlns:local="clr-namespace:MauiDevExpress"
x:Class="MauiDevExpress.MainPage">
<ContentPage.BindingContext>
<local:ViewModel/>
</ContentPage.BindingContext>
<dxc:ChartView>
<dxc:ChartView.Series>
<dxc:LineSeries DisplayName="{Binding GdpValueForUSA.CountryName}">
<dxc:LineSeries.Data>
<dxc:SeriesDataAdapter DataSource="{Binding GdpValueForUSA.Values}"
ArgumentDataMember="Year">
<dxc:ValueDataMember Type="Value" Member="Value"/>
</dxc:SeriesDataAdapter>
</dxc:LineSeries.Data>
</dxc:LineSeries>
<dxc:LineSeries DisplayName="{Binding GdpValueForChina.CountryName}">
<dxc:LineSeries.Data>
<dxc:SeriesDataAdapter DataSource="{Binding GdpValueForChina.Values}"
ArgumentDataMember="Year">
<dxc:ValueDataMember Type="Value" Member="Value"/>
</dxc:SeriesDataAdapter>
</dxc:LineSeries.Data>
</dxc:LineSeries>
<dxc:LineSeries DisplayName="{Binding GdpValueForJapan.CountryName}">
<dxc:LineSeries.Data>
<dxc:SeriesDataAdapter DataSource="{Binding GdpValueForJapan.Values}"
ArgumentDataMember="Year">
<dxc:ValueDataMember Type="Value" Member="Value"/>
</dxc:SeriesDataAdapter>
</dxc:LineSeries.Data>
</dxc:LineSeries>
</dxc:ChartView.Series>
</dxc:ChartView>
</ContentPage>
<dxc:ChartView> <dxc:ChartView.AxisX>
<dxc:DateTimeAxisX MeasureUnit="Year" GridAlignment="Year"
GridSpacing="2"/> </dxc:ChartView.AxisX> </dxc:ChartView>
<dxc:ChartView>
<!-- The X-axis config is here. -->
<dxc:ChartView.AxisY>
<dxc:NumericAxisY>
<dxc:NumericAxisY.Title>
<dxc:AxisTitle Text="Trillions of US$">
<dxc:AxisTitle.Style>
<dxc:TitleStyle>
<dxc:TitleStyle.TextStyle>
<dxc:TextStyle Size="16"/>
</dxc:TitleStyle.TextStyle>
</dxc:TitleStyle>
</dxc:AxisTitle.Style>
</dxc:AxisTitle>
</dxc:NumericAxisY.Title>
<dxc:NumericAxisY.Label>
<dxc:AxisLabel TextFormat="#.#" Position="Inside"/>
</dxc:NumericAxisY.Label>
</dxc:NumericAxisY>
</dxc:ChartView.AxisY>
</dxc:ChartView>
<dxc:ChartView>
<dxc:ChartView.Legend>
<dxc:Legend VerticalPosition="TopOutside"
HorizontalPosition="Center"
Orientation="LeftToRight"/>
</dxc:ChartView.Legend>
</dxc:ChartView>
<ContentPage.Resources>
<dxc:SeriesCrosshairOptions x:Key="lineSeriesHintOptions"
PointTextPattern="{}{S}: {V}M"
ShowInLabel="True"
AxisLabelVisible="True"
AxisLineVisible="True"/>
</ContentPage.Resources>
<dxc:ChartView>
<dxc:ChartView.Hint>
<dxc:Hint>
<dxc:Hint.Behavior>
<dxc:CrosshairHintBehavior GroupHeaderTextPattern="{}{A$YYYY}"
MaxSeriesCount="3"/>
</dxc:Hint.Behavior>
</dxc:Hint>
</dxc:ChartView.Hint>
<dxc:ChartView.Series>
<dxc:LineSeries HintOptions="{StaticResource lineSeriesHintOptions}">
<!--Series Data-->
</dxc:LineSeries>
<dxc:LineSeries HintOptions="{StaticResource lineSeriesHintOptions}">
<!--Series Data-->
</dxc:LineSeries>
<dxc:LineSeries HintOptions="{StaticResource lineSeriesHintOptions}">
<!--Series Data-->
</dxc:LineSeries>
</dxc:ChartView.Series>
</dxc:ChartView>
<dxc:LineSeries MarkersVisible="True">
<!--Series Data-->
<dxc:LineSeries.Style>
<dxc:LineSeriesStyle Stroke="#7145a7" StrokeThickness="2" MarkerSize="8">
<dxc:LineSeriesStyle.MarkerStyle>
<dxc:MarkerStyle Fill="#7145a7"/>
</dxc:LineSeriesStyle.MarkerStyle>
</dxc:LineSeriesStyle>
</dxc:LineSeries.Style>
</dxc:LineSeries>
Introduction Supercharge your .NET MAUI projects with Lottie animations! Imagine it as the magic wand for your app's visuals....
Supercharge your .NET MAUI projects with Lottie animations! Imagine it as the magic wand for your app's visuals. Thanks to Adobe After Effects, Lottie speaks a special language called JSON, making animations a breeze. Meet SkiaSharp, a Microsoft buddy that helps Lottie shine in .NET MAUI, making your app look cool without the complexity. Learn the ropes in our beginner-friendly guide! Add a dash of Lottie, sprinkle in some JSON magic, and watch your app come to life!
using SkiaSharp.Views.Maui.Controls.Hosting;
.UseSkiaSharp()
xmlns:skia="clr-namespace:SkiaSharp.Extended.UI.Controls;assembly=SkiaSharp.Extended.UI"
<skia:SKLottieView RepeatCount="-1"
RepeatMode="Reverse"
Source="walking_batman.json"
HeightRequest="400"
WidthRequest="400" />
<skia:SKLottieView>
: This is the declaration of the SKLottieView, a specialized view for rendering Lottie animations using the SkiaSharp library.
RepeatCount="-1"
: The RepeatCount attribute determines how many times the animation should repeat. A value of -1 means it will repeat indefinitely.
RepeatMode="Reverse"
: The RepeatMode attribute sets the behavior of the animation when it repeats. In this case, "Reverse" means the animation will play in reverse each time it repeats.
Source="walking_batman.json"
: Specifies the source of the Lottie animation. In this example, the animation is loaded from a file named "Girl.json" located in the project.
HeightRequest="400"
and WidthRequest="400"
: These attributes set the desired height and width of the SKLottieView, in this case, both set to 400. This property is very important to visualize Lottie animation.
This code essentially integrates a Lottie animation (from the "walking_batman.json" file) into your Xamarin.Forms application, configuring its repeat behavior and dimensions. Adjust these attributes based on your specific animation and layout requirements.
Introduction Our phones and computers are like magic doors to the world, thanks to the apps we use every day. These apps show us ...
Our phones and computers are like magic doors to the world, thanks to the apps we use every day. These apps show us stuff using a mix of words, pictures, and special links that let us explore more. 🌐 Links, especially, make it easy for us to dive deep into things. In this guide, we'll learn how to add these special links to your .NET MAUI apps, making it more fun for people to check out what you have to share. Join us on this enlightening journey as we unravel the secrets of Transforming Labels into Hyperlinks with .NET MAUI.
<HorizontalStackLayout>
<Label
Text="To know more about .NET MAUI "
SemanticProperties.HeadingLevel="Level1"
FontSize="Default"
HorizontalOptions="Center" />
<Label
Text="Visit Here"
TextDecorations="Underline"
TextColor="Blue"
SemanticProperties.HeadingLevel="Level1"
FontSize="Default"
HorizontalOptions="Center" >
<Label.GestureRecognizers>
<TapGestureRecognizer Tapped="OnUrlClicked"/>
</Label.GestureRecognizers>
</Label>
</HorizontalStackLayout>
private async void OnUrlClicked(object sender, TappedEventArgs e)
{
await Launcher.OpenAsync("https://www.androidmads.info/search/label/.net%20maui");
}
Introduction Welcome to our newest blog post, where we explore the vibrant realm of MVVM (Model-View-ViewModel) architecture usin...
Welcome to our newest blog post, where we explore the vibrant realm of MVVM (Model-View-ViewModel) architecture using the cutting-edge MVVM Toolkit in .NET MAUI. In this comprehensive guide, we will unravel the intricacies of MVVM and demonstrate how the MVVM Toolkit in .NET MAUI empowers developers to create robust, responsive, and easily maintainable cross-platform mobile applications. Join us on this enlightening journey as we unravel the secrets of mastering MVVM in the context of .NET MAUI.
View Model
public partial class ItemEntryPageModel : ObservableObject
{
[ObservableProperty]
private int _id;
[ObservableProperty]
private string _name;
[ObservableProperty]
private string _description;
[ICommand]
public async void Save()
{
await Application.Current.MainPage.DisplayAlert("MAUI MVVM Sample", "Item Saved Successfully", "OK");
}
}
View
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MauiMVVM.Views.ItemEntryPage"
Title="Item Entry">
<StackLayout Margin="20"
Spacing="10">
<VerticalStackLayout>
<Label Text="Name:"
FontSize="16"/>
<Entry Text="{Binding Name}"
Placeholder="Item Name"/>
</VerticalStackLayout>
<VerticalStackLayout>
<Label Text="Description:"
FontSize="16"/>
<Entry Text="{Binding Description}"
Placeholder="Item Description"/>
</VerticalStackLayout>
<Button x:Name="btn_save"
Text="Save"
Command="{Binding SaveCommand}"/>
</StackLayout>
</ContentPage>
Wire-up View and View Model
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
});
#if DEBUG
builder.Logging.AddDebug();
#endif
builder.Services.AddTransient<ItemEntryPage>();
builder.Services.AddTransient<ItemEntryPageModel>();
return builder.Build();
References
To learn more about Data binding and MVVM
Introduction Welcome to our newest blog post, where we explore the vibrant realm of app development with .NET MAUI! In this deta...
A blog about android developement
Welcome to our newest blog post, where we explore the vibrant realm of app development with .NET MAUI! In this detailed guide, we dive into the intricacies of the "DataGrid Control for .NET MAUI," an outstanding free plugin crafted to simplify your data management process. Uncover how this plugin enables developers to effortlessly sort, filter, and present data, elevating user experiences across cross-platform applications.
Telerik, SyncFusion, and DevExpress offer paid licenses, often accompanied by trial versions or community licenses under specific terms. However, DevExpress stands out by providing a set of controls that you can use absolutely free!. As the demand for seamless data visualization and interaction grows, this free plugin emerges as a game-changer for .NET MAUI enthusiasts.
Open MauiProgram.cs file, and add ".UseDevExpress()" in builder like below
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.UseDevExpress()
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
});
Add Namespace in XAML:
In your .NET MAUI XAML files where you intend to use the Dev Express - DataGrid, make sure to add the appropriate XML namespace. For example:
xmlns:dxg="clr-namespace:DevExpress.Maui.DataGrid;assembly=DevExpress.Maui.DataGrid"
xmlns:dxe="clr-namespace:DevExpress.Maui.Editors;assembly=DevExpress.Maui.Editors"
xmlns:dxc="clr-namespace:DevExpress.Maui.Controls;assembly=DevExpress.Maui.Controls"
Adjust the namespace and assembly name based on the specifics of the DataGrid component you installed.
Implement DataGrid in Your XAML:
You can now implement the DataGrid control in your XAML files using the namespace you added. For example:
<dg:DataGrid RefreshingEnabled="True"
BackgroundColor="White"
IsRefreshing="{Binding Refreshing}"
PullToRefreshCommand="{Binding OnDataGridRefreshCommand}"
SelectionEnabled="True"
SelectedItem="{Binding SelectedItem}"
RowHeight="70"
HeaderHeight="70"
ItemsSource="{Binding Items}"
HeaderBackground="Red">
<dg:DataGrid.NoDataView>
<Label Text="Nothing to see here" HorizontalOptions="Center" VerticalOptions="Center" />
</dg:DataGrid.NoDataView>
<dg:DataGrid.Columns>
<dg:DataGridColumn Title="Image" PropertyName="Image" Width="150" SortingEnabled="False">
<dg:DataGridColumn.CellTemplate>
<DataTemplate>
<Image Source="{Binding}" HorizontalOptions="Center" VerticalOptions="Center"
Aspect="AspectFit" HeightRequest="60" />
</DataTemplate>
</dg:DataGridColumn.CellTemplate>
</dg:DataGridColumn>
<dg:DataGridColumn Title="Name" PropertyName="Name" Width="100"/>
<dg:DataGridColumn Title="Location" PropertyName="Location" Width="100"/>
<dg:DataGridColumn Title="Population" PropertyName="Population" Width="100"/>
<dg:DataGridColumn Title="Latitude" PropertyName="Latitude" Width="100"/>
<dg:DataGridColumn Title="Longitude" PropertyName="Longitude" Width="100"/>
</dg:DataGrid.Columns>
<dg:DataGrid.RowsBackgroundColorPalette>
<dg:PaletteCollection>
<Color>#e1e1e1</Color>
<Color>#ffffff</Color>
</dg:PaletteCollection>
</dg:DataGrid.RowsBackgroundColorPalette>
</dg:DataGrid>
The above code snippet represents a DataGrid component in .NET MAUI application. Let's break down the properties and their meanings in the context of this DataGrid:
The below code snippet configures a DataGrid component with specific properties and templates, allowing users to view and interact with data in a visually appealing manner.
The Code Behind or MVVM view model properties are similar to listview control and no specific code required
using System.Collections.ObjectModel;
using System.Net.Http;
using System.Net.Http.Json;
namespace MauiDevExpress
{
public partial class MainPage : ContentPage
{
public MainPage()
{
BindingContext = this;
InitializeComponent();
}
protected override async void OnAppearing()
{
base.OnAppearing();
await Task.Delay(2000);
LoadData();
}
private void LoadData()
{
var monkeys = new List<Monkey>
{
new Monkey
{
Name = "Chimpanzee",
Location = "Africa",
Details = "Chimpanzees are intelligent primates known for their problem-solving abilities.",
Image = "chimpanzee.jpg",
Population = 150000,
Latitude = -1.2921f,
Longitude = 36.8219f,
BirthDate = new DateTime(2000, 1, 15),
AccessLevel = AccessLevel.Admin
},
new Monkey
{
Name = "Orangutan",
Location = "Borneo",
Details = "Orangutans are great apes native to the rainforests of Borneo and Sumatra.",
Image = "orangutan.jpg",
Population = 70000,
Latitude = 1.3521f,
Longitude = 110.4647f,
BirthDate = new DateTime(2005, 3, 20),
AccessLevel = AccessLevel.User
},
new Monkey
{
Name = "Gorilla",
Location = "Africa",
Details = "Gorillas are the largest primates and share about 98.3% of their DNA with humans.",
Image = "gorilla.jpg",
Population = 100000,
Latitude = -0.2280f,
Longitude = 15.8277f,
BirthDate = new DateTime(1998, 7, 10),
AccessLevel = AccessLevel.Admin
},
// Add more monkey instances with BirthDate and AccessLevel properties
new Monkey
{
Name = "Howler Monkey",
Location = "South America",
Details = "Howler monkeys are known for their loud vocalizations that can be heard up to 3 miles away.",
Image = "howler_monkey.jpg",
Population = 50000,
Latitude = -14.2350f,
Longitude = -51.9253f,
BirthDate = new DateTime(2002, 5, 3),
AccessLevel = AccessLevel.User
},
new Monkey
{
Name = "Capuchin Monkey",
Location = "Central and South America",
Details = "Capuchin monkeys are highly intelligent and are often used in scientific research.",
Image = "capuchin_monkey.jpg",
Population = 30000,
Latitude = 4.7100f,
Longitude = -74.0721f,
BirthDate = new DateTime(2007, 9, 18),
AccessLevel = AccessLevel.Admin
},
new Monkey
{
Name = "Spider Monkey",
Location = "Central and South America",
Details = "Spider monkeys are known for their long limbs and prehensile tail, which they use to swing through trees.",
Image = "spider_monkey.jpg",
Population = 25000,
Latitude = 14.634915f,
Longitude = -90.506882f,
BirthDate = new DateTime(1999, 11, 7),
AccessLevel = AccessLevel.User
},
new Monkey
{
Name = "Mandrill",
Location = "Africa",
Details = "Mandrills are colorful monkeys found in the rainforests of Central Africa.",
Image = "mandrill.jpg",
Population = 10000,
Latitude = 0.2280f,
Longitude = 14.8277f,
BirthDate = new DateTime(2004, 2, 14),
AccessLevel = AccessLevel.Admin
},
new Monkey
{
Name = "Tarsier",
Location = "Southeast Asia",
Details = "Tarsiers are small primates known for their big eyes and unique hunting skills.",
Image = "tarsier.jpg",
Population = 5000,
Latitude = 9.3275f,
Longitude = 123.3076f,
BirthDate = new DateTime(2001, 8, 22),
AccessLevel = AccessLevel.User
},
new Monkey
{
Name = "Golden Lion Tamarin",
Location = "Brazil",
Details = "Golden lion tamarins are endangered primates with striking orange fur and manes.",
Image = "golden_lion_tamarin.jpg",
Population = 1500,
Latitude = -22.9068f,
Longitude = -43.1729f,
BirthDate = new DateTime(2006, 12, 5),
AccessLevel = AccessLevel.Admin
},
new Monkey
{
Name = "Proboscis Monkey",
Location = "Borneo",
Details = "Proboscis monkeys have large noses and are excellent swimmers.",
Image = "proboscis_monkey.jpg",
Population = 700,
Latitude = 2.4604f,
Longitude = 115.3502f,
BirthDate = new DateTime(2003, 4, 30),
AccessLevel = AccessLevel.User
},
// Add more monkey instances as needed
// ...
};
dxg.ItemsSource = new ObservableCollection<Monkey>(monkeys);
}
public class Monkey
{
public string Name { get; set; }
public string Location { get; set; }
public string Details { get; set; }
public string Image { get; set; }
public int Population { get; set; }
public float Latitude { get; set; }
public float Longitude { get; set; }
public AccessLevel AccessLevel { get; set; }
public DateTime BirthDate { get; set; }
}
public enum AccessLevel
{
Admin,
User
}
}
}
References
To learn more about DevExpress DataGrid
Introduction Welcome to our latest blog post, where we delve into the dynamic world of app development using .NET MAUI! In this comp...
A blog about android developement
Welcome to our latest blog post, where we delve into the dynamic world of app development using .NET MAUI! In this comprehensive guide, we explore the intricacies of the "DataGrid Control for .NET MAUI," an exceptional free plugin designed to streamline your data management process. Discover how this plugin empowers developers to effortlessly sort, filter, and display data, enhancing user experiences within cross-platform applications.
In our latest article, we unveil the power of the "DataGrid Control for .NET MAUI," an invaluable plugin that simplifies the complexities of data management in cross-platform app development. As the demand for seamless data visualization and interaction grows, this free plugin emerges as a game-changer for .NET MAUI enthusiasts.
Add Namespace in XAML:
In your .NET MAUI XAML files where you intend to use the DataGrid, make sure to add the appropriate XML namespace. For example:
xmlns:dg="clr-namespace:Maui.DataGrid;assembly=Maui.DataGrid"
Adjust the namespace and assembly name based on the specifics of the DataGrid component you installed.
Implement DataGrid in Your XAML:
You can now implement the DataGrid control in your XAML files using the namespace you added. For example:
<dg:DataGrid RefreshingEnabled="True"
BackgroundColor="White"
IsRefreshing="{Binding Refreshing}"
PullToRefreshCommand="{Binding OnDataGridRefreshCommand}"
SelectionEnabled="True"
SelectedItem="{Binding SelectedItem}"
RowHeight="70"
HeaderHeight="70"
ItemsSource="{Binding Items}"
HeaderBackground="Red">
<dg:DataGrid.NoDataView>
<Label Text="Nothing to see here" HorizontalOptions="Center" VerticalOptions="Center" />
</dg:DataGrid.NoDataView>
<dg:DataGrid.Columns>
<dg:DataGridColumn Title="Image" PropertyName="Image" Width="150" SortingEnabled="False">
<dg:DataGridColumn.CellTemplate>
<DataTemplate>
<Image Source="{Binding}" HorizontalOptions="Center" VerticalOptions="Center"
Aspect="AspectFit" HeightRequest="60" />
</DataTemplate>
</dg:DataGridColumn.CellTemplate>
</dg:DataGridColumn>
<dg:DataGridColumn Title="Name" PropertyName="Name" Width="100"/>
<dg:DataGridColumn Title="Location" PropertyName="Location" Width="100"/>
<dg:DataGridColumn Title="Population" PropertyName="Population" Width="100"/>
<dg:DataGridColumn Title="Latitude" PropertyName="Latitude" Width="100"/>
<dg:DataGridColumn Title="Longitude" PropertyName="Longitude" Width="100"/>
</dg:DataGrid.Columns>
<dg:DataGrid.RowsBackgroundColorPalette>
<dg:PaletteCollection>
<Color>#e1e1e1</Color>
<Color>#ffffff</Color>
</dg:PaletteCollection>
</dg:DataGrid.RowsBackgroundColorPalette>
</dg:DataGrid>
The above code snippet represents a DataGrid component in .NET MAUI application. Let's break down the properties and their meanings in the context of this DataGrid:
This code snippet configures a DataGrid component with specific properties and templates, allowing users to view and interact with data in a visually appealing manner.
The Code Behind or MVVM view model properties are similar to listview control and no specific code required
References
To learn more about Swipe View
© 2022, made with ❤ by Androidmads for developers
Follow Us
Were this world an endless plain, and by sailing eastward we could for ever reach new distances