Value Converter In GridViewDataColumn in RadTreeListView colums

3 posts, 1 answers
  1. Manishkumar
    Manishkumar avatar
    240 posts
    Member since:
    Feb 2009

    Posted 02 Sep 2011 Link to this post

    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:GridViewDataColumn x:Name="gvcPlanFinish" DataMemberBinding="{Binding PlanEndDate}" Header="Plan Finish"



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










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




    void SetValueConvertersInColumns()




    GridViewDataColumn gvcPlanFinish = new GridViewDataColumn();



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



    Binding bndText = new Binding("PlanEndDate");


    bndText.Mode =




    TextBlock.TextProperty, bndText);



    Binding bndPlanWorkBackGround = new Binding("PlanEndDate");


    bndPlanWorkBackGround.Converter =

    this.FindResource("PlanFinishBackColorConverterKey") as IValueConverter;



    TextBlock.BackgroundProperty, bndPlanWorkBackGround);




    DataTemplate dataTemplate = new DataTemplate();


    dataTemplate.VisualTree = tbPlanWork;

    gvcPlanFinish.CellTemplate = dataTemplate;


    gvcPlanFinish.DataMemberBinding =

    new Binding("PlanEndDate");


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


  2. Answer
    Pavel Pavlov
    Pavel Pavlov avatar
    2039 posts

    Posted 02 Sep 2011 Link to this post

    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.

    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 >>

  3. DevCraft R3 2016 release webinar banner
  4. Manishkumar
    Manishkumar avatar
    240 posts
    Member since:
    Feb 2009

    Posted 02 Sep 2011 Link to this post

    Thank you so much. I could find my mistake and could successfully develop my requirement.
Back to Top