Good Morning,
It would be nice to have the possibility to choose if use DateTimePicker or DatePicker during the 'AutoGeneratingField' event.
Something like:
if (e.PropertyType.Equals(typeof(DateTime)))
{
e.DateTimeMode = ...RadDataForm.DateTimeMode.OnlyDate, //(or .DateTime)
}
Because overriding the 'DataFormField' content with a RadDateTimePicker is a little bit intricate especially for the binding/reference losing.
The control is very helpful to make fast user forms prototipe but in this case it lose all its convenience.
Thank you,
Best Regards,
Enrico
public
class
CustomDataFormDateField : DataFormDateField
{
private
bool
isDateTimePicker =
false
;
public
bool
IsDateTimePicker
{
get
{
return
isDateTimePicker =
false
; }
set
{ isDateTimePicker = value; }
}
protected
override
Control GetControl()
{
if
(
this
.isDateTimePicker)
{
RadDateTimePicker control =
new
RadDateTimePicker();
if
(
this
.DataMemberBinding !=
null
)
{
control.SetBinding(RadDateTimePicker.SelectedValueProperty,
this
.DataMemberBinding);
}
control.SetBinding(RadDateTimePicker.IsEnabledProperty,
new
Binding(
"IsReadOnly"
) { Source =
this
, Converter =
new
InvertedBooleanConverter() });
return
control;
}
else
{
return
base
.GetControl();
}
}
}
private
void
RadDataForm_AutoGeneratingField(
object
sender, Telerik.Windows.Controls.Data.DataForm.AutoGeneratingFieldEventArgs e)
{
if
(e.PropertyType.Equals(
typeof
(DateTime)))
{
e.DataField =
new
CustomDataFormDateField() { IsDateTimePicker =
true
};
}
}