I created the a custom class using the steps in the documentation to convert data when dragging and dropping. For some reason, this code is never called and the conversion never happens. I set breakpoints in the class and they are never hit. I don't know what I need to do to get the converter to work. Could someone please help me figure out why the code in the convert class isn't getting called?
Thank you.
Here is the XAML:
This is the C# class:
Thank you.
Here is the XAML:
<
DataTemplate
x:Key
=
"LoadBoardListBoxItemTemplate"
>
<
StackPanel
Orientation
=
"Vertical"
Background
=
"{Binding ColorCode, Converter={StaticResource ColorConverter}}"
VerticalAlignment
=
"Stretch"
HorizontalAlignment
=
"Stretch"
>
<
TextBlock
Text
=
"{Binding Company.Name}"
Margin
=
"3"
Foreground
=
"White"
Width
=
"200"
FontSize
=
"12"
VerticalAlignment
=
"Stretch"
HorizontalAlignment
=
"Stretch"
/>
<
TextBlock
Text
=
"{Binding Name}"
Margin
=
"3"
FontSize
=
"12"
Foreground
=
"White"
VerticalAlignment
=
"Stretch"
HorizontalAlignment
=
"Stretch"
/>
<
StackPanel
Orientation
=
"Horizontal"
>
<
TextBlock
Text
=
"Turn Time"
FontSize
=
"12"
Margin
=
"3"
Foreground
=
"White"
VerticalAlignment
=
"Stretch"
HorizontalAlignment
=
"Stretch"
/>
<
TextBlock
Text
=
"{Binding TurnTime}"
FontSize
=
"12"
Margin
=
"3"
Foreground
=
"White"
VerticalAlignment
=
"Stretch"
HorizontalAlignment
=
"Stretch"
/>
</
StackPanel
>
</
StackPanel
>
</
DataTemplate
>
<
Style
x:Key
=
"DraggableListBoxItem"
TargetType
=
"telerik:RadListBoxItem"
>
<
Setter
Property
=
"telerik:DragDropManager.AllowCapturedDrag"
Value
=
"True"
/>
</
Style
>
<
telerik:RadListBox
x:Name
=
"xLoadBoardListBox"
Grid.Row
=
"3"
Grid.Column
=
"1"
ItemsSource
=
"{Binding Trips, Mode=TwoWay}"
IsEnabled
=
"{Binding ListEnabled, Mode=TwoWay}"
ItemContainerStyle
=
"{StaticResource DraggableListBoxItem}"
ItemTemplate
=
"{StaticResource LoadBoardListBoxItemTemplate}"
AllowDrop
=
"True"
>
<
telerik:RadListBox.DragVisualProvider
>
<
telerik:ScreenshotDragVisualProvider
/>
</
telerik:RadListBox.DragVisualProvider
>
<
telerik:RadListBox.DragDropBehavior
>
<
telerik:ListBoxDragDropBehavior
AllowReorder
=
"True"
/>
</
telerik:RadListBox.DragDropBehavior
>
<
telerik:RadListBox.DataConverter
>
<
drag:TripToActualTripConverter
/>
</
telerik:RadListBox.DataConverter
>
</
telerik:RadListBox
>
This is the C# class:
public
class
TripToActualTripConverter : DataConverter
{
public
override
string
[] GetConvertToFormats()
{
return
new
string
[] {
typeof
(Trip).FullName,
typeof
(ActualTrip).FullName };
}
public
override
object
ConvertTo(
object
data,
string
format)
{
var payload = (IEnumerable)DataObjectHelper.GetData(data,
typeof
(Trip),
false
);
if
(payload !=
null
)
{
return
payload.OfType<Trip>().Select(t =>
new
ActualTrip
{
Company = t.Company,
CompanyId = t.CompanyId,
Trip = t,
TripId = t.TripId,
ActualDate = DateTime.Now,
TicketNumber =
string
.Empty,
TripNumber =
string
.Empty,
ActualTons = 0,
Label = t.Name
});
}
return
null
;
}
}