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

Pass through column.UniqueName as ValueConverter parameter?

2 Answers 68 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Steve
Top achievements
Rank 1
Steve asked on 27 May 2011, 09:27 PM
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 Answers, 1 is accepted

Sort by
0
Accepted
Ivan Ivanov
Telerik team
answered on 01 Jun 2011, 02:02 PM
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
0
Steve
Top achievements
Rank 1
answered on 01 Jun 2011, 03:32 PM
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
Tags
GridView
Asked by
Steve
Top achievements
Rank 1
Answers by
Ivan Ivanov
Telerik team
Steve
Top achievements
Rank 1
Share this question
or