This question is locked. New answers and comments are not allowed.
Hi:
I have the following XAML:
This is the converter:
The time from the datetime displays correctly in the cell template but when I go into edit mode, the RadTimePicker displays "Enter date" rather than the time string. What am I doing wrong, and is there a code example for using a time picker in a grid where data is both entered and edited?
Thanks,
Terry
I have the following XAML:
<
radGridView:GridViewDataColumn
Header
=
"Start Time"
DataMemberBinding
=
"{Binding StartTime, Mode=TwoWay}"
>
<
radGridView:GridViewDataColumn.CellTemplate
>
<
DataTemplate
>
<
TextBlock
Text
=
"{Binding StartTime, Converter={StaticResource DateTimeToTimeString2}}"
/>
</
DataTemplate
>
</
radGridView:GridViewDataColumn.CellTemplate
>
<
radGridView:GridViewDataColumn.CellEditTemplate
>
<
DataTemplate
>
<
radInput:RadTimePicker
x:Name
=
"StartTimePicker"
TimeInterval
=
"0:15:0"
SelectedTime
=
"{Binding StartTime, Converter={StaticResource DateTimeToTimeString2}}"
KeyDown
=
"TimePicker_KeyDown"
/>
</
DataTemplate
>
</
radGridView:GridViewDataColumn.CellEditTemplate
>
</
radGridView:GridViewDataColumn
>
This is the converter:
public
class
DateTimeToTimeString2 : IValueConverter
{
#region IValueConverter Members
public
object
Convert(
object
value, Type targetType,
object
parameter, System.Globalization.CultureInfo culture)
{
if
( value ==
null
)
return
null
;
DateTime dt1 = (DateTime) value;
string
x = dt1.ToShortTimeString(); ;
return
x;
}
public
object
ConvertBack(
object
value, Type targetType,
object
parameter, System.Globalization.CultureInfo culture)
{
throw
new
NotImplementedException(
"This Convert supports only OneWay binding"
);
}
#endregion
}
Thanks,
Terry