I display a collection of items in a RadGridView, each having a collection of parameters of possibly different types.
It works quite nicely if I use the resource definitions below along with an identical definition for each of the parameter columns:
It works quite nicely if I use the resource definitions below along with an identical definition for each of the parameter columns:
01.
<
t:RadGridView.Resources
>
02.
<
DataTemplate
DataType
=
"{x:Type vm:AnalogParam}"
>
03.
edit template definition....
04.
</
DataTemplate
>
05.
<
DataTemplate
DataType
=
"{x:Type vm:DigitalParam}"
>
06.
edit template definition....
07.
</
DataTemplate
>
08.
<
DataTemplate
DataType
=
"{x:Type vm:DummyParam}"
>
09.
edit template definition....
10.
</
DataTemplate
>
11.
12.
<
DataTemplate
DataType
=
"{x:Type vm:AnalogParamDisplay}"
>
13.
display template definition....
14.
</
DataTemplate
>
15.
<
DataTemplate
DataType
=
"{x:Type vm:DigitalParamDisplay}"
>
16.
display template definition....
17.
</
DataTemplate
>
18.
<
DataTemplate
DataType
=
"{x:Type vm:DummyParamDisplay}"
>
19.
display template definition....
20.
</
DataTemplate
>
21.
22.
<
DataTemplate
DataType
=
"{x:Type bo:DigitalParamDesc}"
>
23.
header template definition....
24.
</
DataTemplate
>
25.
<
DataTemplate
DataType
=
"{x:Type no:AnalogParamDesc}"
>
26.
header template definition....
27.
</
DataTemplate
>
28.
</
t:RadGridView.Resources
>
29.
<
t:RadGridView.Columns
>
30.
.....
31.
<
t:GridViewDataColumn
Header
=
"{Binding Descriptors[4]}"
IsReadOnly
=
"False"
IsFilterable
=
"False"
>
32.
<
t:GridViewColumn.CellTemplate
>
33.
<
DataTemplate
>
34.
<
ContentPresenter
Content
=
"{Binding Params[4].DisplayWrapper}"
/>
35.
</
DataTemplate
>
36.
</
t:GridViewColumn.CellTemplate
>
37.
<
t:GridViewColumn.CellEditTemplate
>
38.
<
DataTemplate
>
39.
<
ContentPresenter
Content
=
"{Binding Params[4]}"
/>
40.
</
DataTemplate
>
41.
</
t:GridViewColumn.CellEditTemplate
>
42.
</
t:GridViewDataColumn
>
Because the number of parameters in the grid is variable, I would like to add the columns programmatically instead of defining them in XAML.
How do I do that?