DataGrid-style

1 Answer 148 Views
DataGrid
Daniel
Top achievements
Rank 1
Silver
Bronze
Daniel asked on 04 Apr 2022, 04:49 PM

HI,

I want to have in grid verticals lines beween the columns like net.

How is can be done ?

Thanks,

1 Answer, 1 is accepted

Sort by
0
Lance | Manager Technical Support
Telerik team
answered on 04 Apr 2022, 05:53 PM

Hi,

Read the documentation here .NET MAUI DataGrid Documentation | Columns Styling | Telerik UI for .NET MAUI

 

Regards,
Lance | Manager Technical Support
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Daniel
Top achievements
Rank 1
Silver
Bronze
commented on 05 Apr 2022, 06:21 AM

Hi,

How I set the DataGridBorderStyle as implicit style ?

Eliminate duplications.

Thanks,


 <telerikDataGrid:RadDataGrid Grid.Row="4" Grid.Column="0" x:Name="resultsDataGrid"  SelectedItem="{Binding HistoryReportSelectedItem, Mode=TwoWay}" Margin="5"
                AutoGenerateColumns="False"  SelectionMode="Single" SelectionUnit="Row" ItemsSource="{Binding HistoryReportSource, Mode=TwoWay}" HeightRequest="400" >
                <telerikDataGrid:RadDataGrid.AlternateRowBackgroundStyle>
                    <telerikDataGrid:DataGridBorderStyle BackgroundColor="LightBlue"
                                     BorderThickness="1"
                                     BorderColor="BlanchedAlmond"/>
                </telerikDataGrid:RadDataGrid.AlternateRowBackgroundStyle>

                <telerikDataGrid:RadDataGrid.Columns>
                    <telerikDataGrid:DataGridTextColumn PropertyName="Succeded" HeaderText="Results" HeaderStyle="{StaticResource DataGridTextColumnHeaderStyle}">
                        <telerikDataGrid:DataGridTextColumn.CellDecorationStyle >
                            <telerikDataGrid:DataGridBorderStyle 
                                        BorderColor="LightBlue"  
                                         BorderThickness="1"/>
                        </telerikDataGrid:DataGridTextColumn.CellDecorationStyle>
                    </telerikDataGrid:DataGridTextColumn>
                    <telerikDataGrid:DataGridTextColumn PropertyName="Type" HeaderText="Type" HeaderStyle="{StaticResource DataGridTextColumnHeaderStyle}">
                        <telerikDataGrid:DataGridTextColumn.CellDecorationStyle >
                            <telerikDataGrid:DataGridBorderStyle 
                                        BorderColor="LightBlue"  
                                         BorderThickness="1"/>
                        </telerikDataGrid:DataGridTextColumn.CellDecorationStyle>
                    </telerikDataGrid:DataGridTextColumn>
      

Lance | Manager Technical Support
Telerik team
commented on 05 Apr 2022, 01:36 PM

Hi Daniel,

In this case, the CellDecorationStyle is not an actual XAML Style object. Rather, it is an instance of the DataGridBorderStyle object. This means you cannot use techniques like implicit styling.

However, you might be able to reuse an instance of a DataGridBorderStyle object that is defined in the app resources. For example, let's move your DataGridBorderStyle objects into the app-wide resources and assign an x:Key to create a static resource for each:

<Application.Resources>
    <telerikDataGrid:DataGridBorderStyle x:Key="MyLightBlueBorderStyle" BorderColor="LightBlue" BorderThickness="1"/>
    <telerikDataGrid:DataGridBorderStyle x:Key="MyBlanchedAlmondBorderStyle" BorderColor="BlanchedAlmond" BorderThickness="1" />
</Application.Resources>

Now you can reference any static resource by the x:Key value

<telerikDataGrid:RadDataGrid ... AlternateRowBackgroundStyle="{StaticResource MyBlanchedAlmondBorderStyle}">
    <telerikDataGrid:RadDataGrid.Columns>
        <telerikDataGrid:DataGridTextColumn ... CellDecorationStyle="{StaticResource MyLightBlueBorderStyle}" />
        <telerikDataGrid:DataGridTextColumn ... CellDecorationStyle="{StaticResource MyLightBlueBorderStyle}" />

Important

Don't forget that any static resource is just one object in memory that is referenced by other items using the StaticResource markup extension. If something changes or hangs any value on that static object, the consequences affect everything else that is using it.

Tags
DataGrid
Asked by
Daniel
Top achievements
Rank 1
Silver
Bronze
Answers by
Lance | Manager Technical Support
Telerik team
Share this question
or