开发者

Silverlight different controls in Column - DataGrid

I am working on project where I need to put different controls into one column.

So for example we have 3 columns: 1st DataGridCheckBoxColumn 2nd DataGridTextColumn 3rd XXX (DataGridTemplateColumn)

we have some rows filled with data, but for corresponding row in last column - XXX, I need to place different controls like combobox, textbox, datetimepicker depending on underlying data.

Example: [ ] | Text | {Combo Box Control} [X] | Text | {Text Box Control} [X] | Text | {Combo Box Control}

Could You please tell me how it can be done ? Is it possible to achieve that ?

Can it be done by puting ContentControl in DataGridTemplateColumn.CellTemplate> and binding its ContentTemplate property to Converter ?>

Example:

 <DataGridTemplateColumn.CellTemplate>
    <DataTemplate>
       <ContentControl Content="{Binding}" ContentTemplate="{Binding Converter  {StaticResource TemplateSelector}}"/>
    </DataTemplate>>
</DataGridTemplat开发者_如何学CeColumn.CellTemplate>

Best regards kkris1983


To accomplish this, you need a "data template selector" control.

Unfortunately, Silverlight does not come with one, but there are several out there on the internet that you can see (e.g. http://www.codeproject.com/KB/silverlight/SLTemplateSelector.aspx).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜