Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
2092
Dynamic binding and column building
posted

I have a grid (Silverlight3 built-in) where I build all the columns dynamically by setting the itemssource to a dictionary object. I bind all columns to the same property and then use converters with converter parameter to fetch the correct value from the dictionary.

I want to use the same solution but just with your grid (XamWebGrid). I'm not very familiar yet with your grid so I may be doing things completely the wrong way. I used the Key property of the TextColumn to "bind" the column to a certain property. This works fine first time but on second column I get an error that I must have unique Key names.

Is it possible for me to bind all columns to the same property? I found the ValueConverter and ValueConverterParameter properties of the TextColumn which I can use to achieve the rest of my requirements.

Parents
No Data
Reply
  • 40030
    Offline posted

    Hi, 

    Yes, but you'd need to use the TemplateColumn, instead of the TextColumn.  In which case, you would use the ItemTemplate property, and provide a DataTemplate, with your Binding and Converter:
    <DataTemplate>
         <TextBlock Text={Binding Prop, Converter={StaticResource MyConverter}, ConverterParameter=Test}/> </DataTemplate>

    Then, for each column, you would provide a unique key, as the key on a TemplateColumn doesn't require a link between the underlying data.

    -SteveZ 

Children