Skip to content

Commit cb768bf

Browse files
committed
Added UG content for Grid cell border customization.
1 parent e31ac21 commit cb768bf

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed
27 KB
Loading

MAUI/DataGrid/conditional-styling.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,64 @@ 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 Border Color for a Specific Cell in SfDataGrid
394+
You can apply styling to a specific cell in the SfDataGrid by targeting the DataGridCell and using the RowIndex and ColumnIndex properties along with the BorderColor property. This allows you to customize the appearance of individual cells, such as setting a unique border color. Additionally, you can customize the thickness of the border using the [GridLineStrokeThickness](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.DataGrid.DataGridStyle.html#Syncfusion_Maui_DataGrid_DataGridStyle_GridLineStrokeThicknessProperty) property.
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+
414+
<syncfusion:SfDataGrid.DefaultStyle>
415+
<syncfusion:DataGridStyle GridLineStrokeThickness="5" />
416+
</syncfusion:SfDataGrid.DefaultStyle>
417+
</syncfusion:SfDataGrid>
418+
</Grid>
419+
</ContentPage.Content>
420+
</ContentPage>
421+
{% endhighlight %}
422+
{% highlight xaml tabtitle="BorderColorConverter.cs" %}
423+
424+
public class BorderColorConverter : IValueConverter
425+
{
426+
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
427+
{
428+
var gridCell = value as DataGridCell;
429+
430+
if (gridCell != null)
431+
{
432+
if (gridCell.DataColumn!.RowIndex == 4 && gridCell.DataColumn.ColumnIndex == 3)
433+
return Colors.Blue;
434+
435+
return Colors.Transparent;
436+
}
437+
438+
return Colors.Transparent;
439+
}
440+
441+
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
442+
{
443+
throw new NotImplementedException();
444+
}
445+
}
446+
{% endhighlight %}
447+
{% endtabs %}
448+
449+
![Conditional cell styling based on RowIndex and ColumnIndex in .NET MAUI DataGrid](Images/conditional-styling/maui-datagrid-conditional-datagridcelltyle_bordercolor_basedon_rowcolumnindex.png)
450+
393451
## Style a cell based on cell value
394452
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.
395453

0 commit comments

Comments
 (0)