This is a migrated thread and some comments may be shown as answers.

Iterate between all cells in RadGridView in WPF

1 Answer 129 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Kishan
Top achievements
Rank 1
Kishan asked on 21 May 2018, 07:34 PM

Hello,

I'm shifting my code from .NET WinForms to Telerik UI for WPF. I want to iterate through all the cells to read it's value and also change it's background color. But I can not find any property like Rows (which I've been using in WinForms) in RadGridView for WPF. I tried searching on google but couldn't find anything useful.

Can someone please help me with how we can iterate through all cells to read it's value using Row Index and Column Index?

I'm very new to WPF and Telerik so it would be useful if anyone can provide a code sample too.

 

 

1 Answer, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 23 May 2018, 11:19 AM
Hello Kishan,

RadGridView for WPF doesn't provide a convenient API to iterate through its cells directly. Instead, you can get the corresponding cell value via the ItemsSource collection. To change the background of a cell you can use the RowStyle of RadGridView. This will allow you to define a Brush property in the row custom model and then bind it to the Background of the GridViewRow control. For example.
<telerik:RadGridView.RowStyle>
    <Style TargetType="telerik:GridViewRow">
        <Setter Property="Background" Value="{Binding MyBrush}"/>
    </Style>
</telerik:RadGridView.RowStyle>

If you tell me why you need to get the values of all cells I will think of an approach to suggest you.

Regards,
Martin Ivanov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
General Discussions
Asked by
Kishan
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Share this question
or