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

[Solved] How to get a control in CellContentTemplate?

4 Answers 126 Views
Grid for XAML
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Cheri
Top achievements
Rank 1
Cheri asked on 22 May 2014, 04:09 PM
Hello,

I have the following column defined:

                    <TelerikGrid:DataGridTemplateColumn Header="DOSE" x:Name="colDose" >
                        <TelerikGrid:DataGridTemplateColumn.CellContentTemplate >
                            <DataTemplate>
                                <TextBlock Margin="5,12" Foreground="{Binding  Converter={StaticResource DoseAlertConverter}}" x:Name="tbDose">
                                    <Run Text="{Binding Dose, Converter={StaticResource RateConverter}}"/>
                                    <Run Text="{Binding Dose, Converter={StaticResource UOMConverter}, ConverterParameter=1}"/>
                                </TextBlock>
                            </DataTemplate>
                        </TelerikGrid:DataGridTemplateColumn.CellContentTemplate>
                    </TelerikGrid:DataGridTemplateColumn>

How do I programmatically access the text block?  I've done this before with other parent controls but can't seem to figure it out with RadDataGrid.
Many Thanks,
Cheri




4 Answers, 1 is accepted

Sort by
0
Ivaylo Gergov
Telerik team
answered on 27 May 2014, 08:53 AM
Hi,

The RadDataGrid uses UI Virtualization so it would not be possible to programmatically access each cell explicitly. For such purposes you can use different approaches like CellContentStyleSelectorCellDecorationStyleSelector or CellContentTemplateSelector. Could you please elaborate more on your scenario, thus I can suggest the best approach?


Regards,
Ivaylo Gergov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Cheri
Top achievements
Rank 1
answered on 07 Aug 2014, 05:31 PM
Sorry for the delay!  

I would like to change the foreground of the textbox based on the bound value.

Many Thanks.
0
Cheri
Top achievements
Rank 1
answered on 11 Aug 2014, 05:04 PM
I understand I need to use CellContentStyleSelector to change the foreground but how do/can  I use it on a DataGridTemplateColumn?  I need to use a converter on the data so (I think) I'm forced to use the DataGridTemplateColumn instead of DataGridTextColumn.

Thanks
0
Rosy Topchiyska
Telerik team
answered on 12 Aug 2014, 03:56 PM
Hello Cheri,

I have attached a sample project that demonstrates how you can use a DataGridTemplateColumn and set a custom foreground depending on the data item. Please, take a look and let us know if you have further questions.

Regards,
Rosy Topchiyska
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid for XAML
Asked by
Cheri
Top achievements
Rank 1
Answers by
Ivaylo Gergov
Telerik team
Cheri
Top achievements
Rank 1
Rosy Topchiyska
Telerik team
Share this question
or