Skip to content

Commit a07bcbc

Browse files
Merge pull request #3760 from syncfusion-content/bordercolor-hotfix
[Hotfix] Added UG for Border Customization for specific Grid cells in SfDataGrid
2 parents b776191 + a48117e commit a07bcbc

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed
27 KB
Loading

MAUI/DataGrid/conditional-styling.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,60 @@ public class ForeColorConverter : IValueConverter
390390

391391
![Conditional cell styling based on RowIndex and ColumnIndex in .NET MAUI DataGrid](Images/conditional-styling/maui-datagrid-conditional-datagridcelltyle_basedon_rowcolumnindex.png)
392392

393+
### Customizing the BorderColor of a cell
394+
You can customize the border color of individual cells in the SfDataGrid based on RowIndex and ColumnIndex property, and setting the `BorderColor` property in DataGridCell by writing the style for the [DataGridCell](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.DataGrid.DataGridCell.html)
395+
396+
{% tabs %}
397+
{% highlight xaml tabtitle="MainPage.xaml" %}
398+
<ContentPage xmlns:syncfusion=http://schemas.syncfusion.com/maui>
399+
<ContentPage.Resources>
400+
<ResourceDictionary>
401+
<local:BorderColorConverter x:Key="converter" />
402+
<Style TargetType="syncfusion:DataGridCell">
403+
<Setter Property="BorderColor" Value="{Binding Source={RelativeSource Mode=Self}, Converter={StaticResource converter}}" />
404+
</Style>
405+
</ResourceDictionary>
406+
</ContentPage.Resources>
407+
408+
<ContentPage.Content>
409+
<Grid>
410+
<syncfusion:SfDataGrid x:Name="dataGrid"
411+
ItemsSource="{Binding OrderInfoCollection}"
412+
GridLinesVisibility="Both">
413+
</syncfusion:SfDataGrid>
414+
</Grid>
415+
</ContentPage.Content>
416+
</ContentPage>
417+
{% endhighlight %}
418+
{% highlight xaml tabtitle="BorderColorConverter.cs" %}
419+
420+
public class BorderColorConverter : IValueConverter
421+
{
422+
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
423+
{
424+
var gridCell = value as DataGridCell;
425+
426+
if (gridCell != null)
427+
{
428+
if (gridCell.DataColumn!.RowIndex == 4 && gridCell.DataColumn.ColumnIndex == 3)
429+
return Colors.Blue;
430+
431+
return Colors.Transparent;
432+
}
433+
434+
return Colors.Transparent;
435+
}
436+
437+
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
438+
{
439+
throw new NotImplementedException();
440+
}
441+
}
442+
{% endhighlight %}
443+
{% endtabs %}
444+
445+
![Customizing the BorderColor of a cell based on RowIndex and ColumnIndex in .NET MAUI DataGrid](Images/conditional-styling/maui-datagrid-customizing-bordercolor_basedon_rowcolumnindex.png)
446+
393447
## Style a cell based on cell value
394448
Styling can be applied to a particular cell based on CellValue property by writing the style for the [DataGridCell](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.DataGrid.DataGridCell.html) TargetType.
395449

0 commit comments

Comments
 (0)