I've managed some fairly complicated controls, using RadDataForm, but now I'm trying something very simple, and it's not working.
The issue: I'm trying to create a user control that contains a RadDataForm that edits one object. There's no readonly, no newitem, no selection of previous or next, there's one single object that should always be displayed in edit mode.
So, I declare a RadDataForm, and bind CurrentItem, but don't bind ItemsSource, and set AutoEdit="True":
The two templates at this point simply contain labels, declaring "EditItemplate" and "ReadonlyTemplate", so I can see which is being loaded. The code-behind is simple:
My problem? The form loads the readonly template, instead of the edit template.
Why?
The issue: I'm trying to create a user control that contains a RadDataForm that edits one object. There's no readonly, no newitem, no selection of previous or next, there's one single object that should always be displayed in edit mode.
So, I declare a RadDataForm, and bind CurrentItem, but don't bind ItemsSource, and set AutoEdit="True":
<
telerik:RadDataForm
x:Name
=
"radDataForm"
CurrentItem
=
"{Binding Path=DataContext.recordData,
RelativeSource={RelativeSource AncestorType=UserControl},
Converter={StaticResource debugBindingConverter}}"
EditTemplate
=
"{StaticResource editTemplate}"
ReadOnlyTemplate
=
"{StaticResource readonlyTemplate}"
AutoEdit
=
"True"
AutoGenerateFields
=
"False"
/>
The two templates at this point simply contain labels, declaring "EditItemplate" and "ReadonlyTemplate", so I can see which is being loaded. The code-behind is simple:
public
partial
class
MyUserControl : KorUserControl
{
public
MyUserControl()
{
InitializeComponent();
this
.DataContext =
new
MyUserControlVM();
}
}
public
class
MyUserControlVM
{
public
RecordData recordData
{
get
;
set
; }
public
MyUserControlVM()
{
this
.recordData =
new
RecordData();
}
}
public
class
RecordData : INotifyPropertyChanged, IDataErrorInfo, IEditableObject
{
public
string
aTestField
{
get
;
set
; }
#region INotifyPropertyChanged Members
...
#endregion
#region IDataErrorInfo Members
...
#endregion
#region IEditableObject Members
...
#endregion
}
My problem? The form loads the readonly template, instead of the edit template.
Why?