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

Value Converter In GridViewDataColumn in RadTreeListView colums

2 Answers 93 Views
TreeListView
This is a migrated thread and some comments may be shown as answers.
Manishkumar
Top achievements
Rank 1
Manishkumar asked on 02 Sep 2011, 11:21 AM
Hi,
I am having an issue in binding a Value Converter in a GridViewDataColumn in RadTreeListView columns. If i add the same to DataTemplate then it works fine. Is there any way to directly use with the GridViewDataColumn .

Please find the code below.

This does not work.

<

 

telerik:RadTreeListView x:Name="rtlvPeopleInfo" >

 

 

 

 

    <telerik:RadTreeListView.Columns>

 

 

 

        <telerik:GridViewDataColumn x:Name="gvcPlanFinish" DataMemberBinding="{Binding PlanEndDate}" Header="Plan Finish"

 

 

                Background="{Binding PlanEndDate, Converter={StaticResource PlanFinishBackColorConverterKey}}" 
                DataFormatString="{}{0:MM-dd-yyyy}" />

 

 

 

 

    </telerik:RadTreeListView.Columns>

 

 

 

</telerik:RadTreeListView>

But if i am doing the same in code behind with data template that works fine

 

private

 

void SetValueConvertersInColumns()

 

{

 

GridViewDataColumn gvcPlanFinish = new GridViewDataColumn();

 

 

FrameworkElementFactory tbPlanWork = new FrameworkElementFactory(typeof(TextBlock));

 

 

Binding bndText = new Binding("PlanEndDate");

 

bndText.Mode =

BindingMode.TwoWay;

 

tbPlanWork.SetBinding(

TextBlock.TextProperty, bndText);

 

 

Binding bndPlanWorkBackGround = new Binding("PlanEndDate");

 

bndPlanWorkBackGround.Converter =

this.FindResource("PlanFinishBackColorConverterKey") as IValueConverter;

 

tbPlanWork.SetBinding(

TextBlock.BackgroundProperty, bndPlanWorkBackGround);

 

 

 

DataTemplate dataTemplate = new DataTemplate();

 

dataTemplate.VisualTree = tbPlanWork;

gvcPlanFinish.CellTemplate = dataTemplate;

gvcPlanFinish.CellTemplate.Seal();

gvcPlanFinish.DataMemberBinding =

new Binding("PlanEndDate");

 

rtlvTreeListView.Columns.Add(gvcPlanFinish); //Adding the new column

}

2 Answers, 1 is accepted

Sort by
0
Accepted
Pavel Pavlov
Telerik team
answered on 02 Sep 2011, 12:12 PM
Hi Manishkumar,

You should not set the background of the whole column as you need the color set at cell level.
If you need this done in XAML , you can do it by defining the same cell template in XAML .

As a side note, it seems you are trying to implement conditional cell formatting . the recommended way of doing this is to use a CellStyleSelector.

Greetings,
Pavel Pavlov
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Manishkumar
Top achievements
Rank 1
answered on 02 Sep 2011, 12:55 PM
Thank you so much. I could find my mistake and could successfully develop my requirement.
Tags
TreeListView
Asked by
Manishkumar
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Manishkumar
Top achievements
Rank 1
Share this question
or