Pass through column.UniqueName as ValueConverter parameter?

3 posts, 1 answers
  1. Steve
    Steve avatar
    19 posts
    Member since:
    Apr 2009

    Posted 27 May 2011 Link to this post

    I am creating dymanic columns (GridViewColumn) in code and assigning a DataTemplate to the column's CellTemplate. Dynamic columns are needed because the number of columns are not known. Here is my DataTemplate...

    <local:QualImageConverter x:Key="QualImageConverter"/>
    <DataTemplate x:Key="imageColumnDataTemplate">
       <Image Source="{Binding Converter={StaticResource QualImageConverter}}"
              HorizontalAlignment="Center" VerticalAlignment="Center"/>
    </DataTemplate>

    The object value that is passed through to the ValueConverter is my bound object. The problem is that I don't know which column I am on. The image displayed in the cell is multiple levels deep off of my bound object and I need to find it by key (which I have set as the UniqueName of the column).

    I have already done this using an Infragistics silverlight grid as the object value passed to the ValueConverter is their UnboundColumnDataContext. Since I am only getting the bound object I have no reference to the cell or column.

    How can I figure out within the ValueConverter or by passing in something through the ConverterParameter to know what cell/column I am in?

    p.s. I am using Silverlight 5 beta so RelativeSource is better (if that would help in this situation).

    Thanks,
    Steve

  2. Answer
    Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    964 posts
    Member since:
    Sep 2012

    Posted 01 Jun 2011 Link to this post

    Hi Steve,

    You will hardly benefit from RelativeSource binding in this very case as this binding is associated with an element placed in a DataTemplate. I have prepared a project illustrating a possible approach to your issue. The only difference in the architecture is that I am using GridViewImageColumn instead of templated GridViewDataColumns. Please, refer to the attached project and let me know if this solution meets your requirements.

    Greetings,
    Ivan Ivanov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

  3. DevCraft Release
  4. Steve
    Steve avatar
    19 posts
    Member since:
    Apr 2009

    Posted 01 Jun 2011 Link to this post

    Ivan,

    Thank you for the sample code. I implemented it a little different to meet my needs but the sample showed me exactly what I needed to do.

    Thank you very much!

    Steve

Back to Top