Skip to content

Commit 1e49f38

Browse files
Merge pull request #1 from Tamilarasan-Paranthaman/master
How to add SfBadgeView in a DataGridTemplateColumn in MAUI DataGrid (SfDataGrid)?
2 parents 31f95c5 + 97d7503 commit 1e49f38

39 files changed

+1266
-1
lines changed

MauiApp1.sln

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.7.34031.279
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MauiApp1", "MauiApp1\MauiApp1.csproj", "{301ED092-94DD-43FF-89A7-EA5DDEFFDEBD}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{301ED092-94DD-43FF-89A7-EA5DDEFFDEBD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{301ED092-94DD-43FF-89A7-EA5DDEFFDEBD}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{301ED092-94DD-43FF-89A7-EA5DDEFFDEBD}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
17+
{301ED092-94DD-43FF-89A7-EA5DDEFFDEBD}.Release|Any CPU.ActiveCfg = Release|Any CPU
18+
{301ED092-94DD-43FF-89A7-EA5DDEFFDEBD}.Release|Any CPU.Build.0 = Release|Any CPU
19+
{301ED092-94DD-43FF-89A7-EA5DDEFFDEBD}.Release|Any CPU.Deploy.0 = Release|Any CPU
20+
EndGlobalSection
21+
GlobalSection(SolutionProperties) = preSolution
22+
HideSolutionNode = FALSE
23+
EndGlobalSection
24+
GlobalSection(ExtensibilityGlobals) = postSolution
25+
SolutionGuid = {F888FEC8-597B-45CD-AD10-143013EA7771}
26+
EndGlobalSection
27+
EndGlobal

MauiApp1/App.xaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version = "1.0" encoding = "UTF-8" ?>
2+
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
4+
xmlns:local="clr-namespace:MauiApp1"
5+
x:Class="MauiApp1.App">
6+
<Application.Resources>
7+
<ResourceDictionary>
8+
<ResourceDictionary.MergedDictionaries>
9+
<ResourceDictionary Source="Resources/Styles/Colors.xaml" />
10+
<ResourceDictionary Source="Resources/Styles/Styles.xaml" />
11+
</ResourceDictionary.MergedDictionaries>
12+
</ResourceDictionary>
13+
</Application.Resources>
14+
</Application>

MauiApp1/App.xaml.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
namespace MauiApp1
2+
{
3+
public partial class App : Application
4+
{
5+
public App()
6+
{
7+
InitializeComponent();
8+
9+
MainPage = new AppShell();
10+
}
11+
}
12+
}

MauiApp1/AppShell.xaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<Shell
3+
x:Class="MauiApp1.AppShell"
4+
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
5+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
6+
xmlns:local="clr-namespace:MauiApp1"
7+
Shell.FlyoutBehavior="Disabled">
8+
9+
<ShellContent
10+
Title="Home"
11+
ContentTemplate="{DataTemplate local:MainPage}"
12+
Route="MainPage" />
13+
14+
</Shell>

MauiApp1/AppShell.xaml.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace MauiApp1
2+
{
3+
public partial class AppShell : Shell
4+
{
5+
public AppShell()
6+
{
7+
InitializeComponent();
8+
}
9+
}
10+
}

MauiApp1/MainPage.xaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
4+
xmlns:local="clr-namespace:MauiApp1"
5+
xmlns:dataGrid="clr-namespace:Syncfusion.Maui.DataGrid;assembly=Syncfusion.Maui.DataGrid"
6+
xmlns:badge="clr-namespace:Syncfusion.Maui.Core;assembly=Syncfusion.Maui.Core"
7+
x:Class="MauiApp1.MainPage">
8+
<ContentPage.BindingContext>
9+
<local:EmployeeInfoRepository/>
10+
</ContentPage.BindingContext>
11+
12+
<dataGrid:SfDataGrid x:Name="dataGrid" ItemsSource="{Binding OrderInfoCollection}" ColumnWidthMode="Auto">
13+
<dataGrid:SfDataGrid.Columns>
14+
<dataGrid:DataGridTemplateColumn MappingName="TaskAssigned"
15+
HeaderText="Task Assigned">
16+
<dataGrid:DataGridTemplateColumn.CellTemplate>
17+
<DataTemplate>
18+
<Grid Margin="50,0,0,0">
19+
<Grid.RowDefinitions>
20+
<RowDefinition Height="*"/>
21+
</Grid.RowDefinitions>
22+
<Grid.ColumnDefinitions>
23+
<ColumnDefinition Width="50"/>
24+
<ColumnDefinition Width="50"/>
25+
</Grid.ColumnDefinitions>
26+
<Label HorizontalOptions="Center" VerticalOptions="Center" Text="{Binding TaskAssigned}" Grid.Column="0" Grid.Row="0"/>
27+
<badge:SfBadgeView BadgeText="{Binding TaskPending}" HorizontalOptions="Start" VerticalOptions="Start">
28+
<badge:SfBadgeView.BadgeSettings>
29+
<badge:BadgeSettings Type="None" TextColor="Red" FontSize="12" FontAttributes="Bold" CornerRadius="10" Position="TopRight" Grid.Column="1" Grid.Row="0"/>
30+
</badge:SfBadgeView.BadgeSettings>
31+
</badge:SfBadgeView>
32+
</Grid>
33+
</DataTemplate>
34+
</dataGrid:DataGridTemplateColumn.CellTemplate>
35+
</dataGrid:DataGridTemplateColumn>
36+
</dataGrid:SfDataGrid.Columns>
37+
</dataGrid:SfDataGrid>
38+
</ContentPage>
39+
40+

MauiApp1/MainPage.xaml.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+

2+
using Syncfusion.Maui.DataGrid;
3+
using System.Globalization;
4+
5+
namespace MauiApp1
6+
{
7+
8+
public partial class MainPage : ContentPage
9+
{
10+
11+
public MainPage()
12+
{
13+
InitializeComponent();
14+
dataGrid.AutoGeneratingColumn += SfDataGrid_AutoGeneratingColumn;
15+
}
16+
17+
private void SfDataGrid_AutoGeneratingColumn(object sender, DataGridAutoGeneratingColumnEventArgs e)
18+
{
19+
if ( e.Column.MappingName == "TaskPending")
20+
{
21+
e.Cancel = true;
22+
}
23+
}
24+
}
25+
}
26+
27+

MauiApp1/MauiApp1.csproj

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFrameworks>net7.0-android;net7.0-ios;net7.0-maccatalyst</TargetFrameworks>
5+
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net7.0-windows10.0.19041.0</TargetFrameworks>
6+
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
7+
<!-- <TargetFrameworks>$(TargetFrameworks);net7.0-tizen</TargetFrameworks> -->
8+
<OutputType>Exe</OutputType>
9+
<RootNamespace>MauiApp1</RootNamespace>
10+
<UseMaui>true</UseMaui>
11+
<SingleProject>true</SingleProject>
12+
<ImplicitUsings>enable</ImplicitUsings>
13+
14+
<!-- Display name -->
15+
<ApplicationTitle>MauiApp1</ApplicationTitle>
16+
17+
<!-- App Identifier -->
18+
<ApplicationId>com.companyname.mauiapp1</ApplicationId>
19+
<ApplicationIdGuid>1eab699a-41e7-418d-83b2-1285c95fedef</ApplicationIdGuid>
20+
21+
<!-- Versions -->
22+
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
23+
<ApplicationVersion>1</ApplicationVersion>
24+
25+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">11.0</SupportedOSPlatformVersion>
26+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">13.1</SupportedOSPlatformVersion>
27+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
28+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
29+
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
30+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
31+
</PropertyGroup>
32+
33+
<ItemGroup>
34+
<!-- App Icon -->
35+
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" />
36+
37+
<!-- Splash Screen -->
38+
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128" />
39+
40+
<!-- Images -->
41+
<MauiImage Include="Resources\Images\*" />
42+
<MauiImage Update="Resources\Images\dotnet_bot.svg" BaseSize="168,208" />
43+
44+
<!-- Custom Fonts -->
45+
<MauiFont Include="Resources\Fonts\*" />
46+
47+
<!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
48+
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
49+
</ItemGroup>
50+
51+
<ItemGroup>
52+
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="7.0.0" />
53+
<PackageReference Include="Syncfusion.Maui.DataGrid" Version="23.1.43" />
54+
</ItemGroup>
55+
56+
</Project>

MauiApp1/MauiApp1.csproj.user

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<IsFirstTimeProjectOpen>False</IsFirstTimeProjectOpen>
5+
<ActiveDebugFramework>net7.0-windows10.0.19041.0</ActiveDebugFramework>
6+
<ActiveDebugProfile>Windows Machine</ActiveDebugProfile>
7+
</PropertyGroup>
8+
</Project>

MauiApp1/MauiProgram.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using Microsoft.Extensions.Logging;
2+
using Syncfusion.Maui.Core.Hosting;
3+
4+
namespace MauiApp1
5+
{
6+
public static class MauiProgram
7+
{
8+
public static MauiApp CreateMauiApp()
9+
{
10+
var builder = MauiApp.CreateBuilder();
11+
builder
12+
.UseMauiApp<App>()
13+
.ConfigureSyncfusionCore()
14+
.ConfigureFonts(fonts =>
15+
{
16+
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
17+
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
18+
});
19+
20+
#if DEBUG
21+
builder.Logging.AddDebug();
22+
#endif
23+
24+
return builder.Build();
25+
}
26+
}
27+
}

0 commit comments

Comments
 (0)