I have a RadDataForm using custom controls via a template and is bound and displays fine, I am having trouble populating the RadComboBoxes inside the RadDataForm and then having the correct item selected. I am populating an observablecollection and setting that to the dataforms itemsSource. This works fine. I as well populate another observablecollection and attempt to set that to a radcombobox inside the raddataform by using RadDataForm.FindName("AppointmentTypeList") in the MainPage.xaml.cs.
Also already read this and still not sure:
http://www.telerik.com/help/silverlight/raddatafor-edit-lookup-values-with-radcombobox.html
I suppose there is something with ViewModel, and I have no clue how to use this or have it interface with my object and the radcombobox.
Environment Facts: Silverlight 4, Windows 7, iExplorer 8.0.7601.17514, RadControls_for_Silverlight_4_2011_1_0419, C#
XAML:
<
DataTemplate
x:Key
=
"AppointmentItemTemplate"
x:Name
=
"AppointmentItemTemplate"
>
<
StackPanel
Orientation
=
"Horizontal"
>
<
Grid
Background
=
"White"
>
<
TextBox
HorizontalAlignment
=
"Left"
VerticalAlignment
=
"Center"
Grid.Row
=
"1"
Grid.Column
=
"1"
Margin
=
"20,0,0,0"
Width
=
"250"
x:Name
=
"AppointmentTitle"
Text
=
"{Binding AppointmentTitle, Mode=TwoWay}"
/>
<
telerik:RadComboBox
HorizontalAlignment
=
"Left"
VerticalAlignment
=
"Center"
Grid.Row
=
"4"
Grid.Column
=
"1"
Name
=
"AppointmentTypeList"
SelectedValuePath
=
"AppointmentAppointmentTypeId"
DisplayMemberPath
=
"AppointmentTypeName"
/>
</
Grid
>
</
StackPanel
>
</
DataTemplate
>
<
telerik:RadDataForm
HorizontalAlignment
=
"Left"
VerticalAlignment
=
"Top"
Height
=
"420"
Width
=
"520"
Name
=
"AppointmentTemplateForm"
Header
=
"Appointment Template Form"
Visibility
=
"Collapsed"
AutoGenerateFields
=
"False"
ReadOnlyTemplate
=
"{StaticResource AppointmentItemTemplate}"
EditTemplate
=
"{StaticResource AppointmentItemTemplate}"
NewItemTemplate
=
"{StaticResource AppointmentItemTemplate}"
EditEnded
=
"AppointmentTemplateForm_EditEnded"
>
</
telerik:RadDataForm
>
//An observable collection is used to hold the items
private
ObservableCollection<AppointmentTypeItem> appointmentTypeItems;
//Observable collection is populated via SOAP
//Code not working – used to load items into the combobox
RadComboBox appointmentTypesBox = (RadComboBox)AppointmentTemplateForm.FindName(
"AppointmentTypeList"
);
appointmentTypesBox.ItemsSource = appointmentTypeItems;
//Base Object Bound to DataForm:
public
class
AppointmentTemplateItem
{
private
EntityReference appointmentAppointmentTypeId;
//Value used to select correct DropDown Item.
public
EntityReference AppointmentAppointmentTypeId {
get
{
return
this
.appointmentAppointmentTypeId; }
set
{
this
.appointmentAppointmentTypeId = value; } }
}
//Class that defines the object to be bound to the RadComboBox
public
class
AppointmentTypeItem
{
private
Guid appointmentTypeId;
private
String appointmentTypeName;
public
AppointmentTypeItem() { }
public
AppointmentTypeItem(Guid appointmentTypeId, String appointmentTypeName)
{
AppointmentTypeId = appointmentTypeId;
AppointmentTypeName = appointmentTypeName;
}
public
Guid AppointmentTypeId {
get
{
return
this
.appointmentTypeId; }
set
{
this
.appointmentTypeId = value; } }
public
String AppointmentTypeName {
get
{
return
this
.AppointmentTypeName; }
set
{
this
.appointmentTypeName = value; } }
}