or
this
.AddHandler(RadComboBox.GotFocusEvent,
new
RoutedEventHandler(comboGotFocus));
void
comboGotFocus(
object
sender, RoutedEventArgs args)
{
GridViewCell cell = args.OriginalSource
as
GridViewCell;
if
(cell !=
null
&& cell.Column.UniqueName ==
"RegionId"
)
{
District district = cell.DataContext
as
District;
if
(district !=
null
&& cell.Content
is
LookupElement)
{
string
countryId = district.CountryId;
RadGridView gridView = (RadGridView)
this
.districtRegistryControl.ChildrenOfType<RadGridView>().First();
RadComboBox comboBox = (cell.Content
as
LookupElement).ComboBox;
if
(comboBox !=
null
)
{
comboBox.ItemsSource =
null
;
if
(
string
.IsNullOrEmpty(countryId) ==
false
)
comboBox.ItemsSource = from r
in
iGasContext.Context.Regions
where r.CountryId == countryId
select r;
else
comboBox.ItemsSource = iGasContext.Context.Regions;
}
}
}
}
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?