If a ReorderListBox will throw a NullReferenceException when used in a winform hybrid application. the reason is that the DragPreviewAdorner uses Application.Current, but this static property is not assigned when running in a winform application. A solution is to change the following method:
private static void GetCurrentDPI(out double x, out double y)
{
Matrix m = PresentationSource.FromVisual(Application.Current.MainWindow).CompositionTarget.TransformToDevice;
x = 96 / m.M11;
y = 96 / m.M22;
}
to
private static void GetCurrentDPI(out double x, out double y, FrameworkElement element)
{
Matrix m = PresentationSource.FromVisual(element).CompositionTarget.TransformToDevice;
x = 96 / m.M11;
y = 96 / m.M22;
}
and pass the current element in SetPreviewElement:
public void SetPreviewElement(FrameworkElement element)
{
//...
GetCurrentDPI(out x, out y, element);
Side note: the class NotifyWorker seems to have the same issue in the OnClientException method... haven't looked at how that could be handled. We aren't using that class.
If a ReorderListBox will throw a NullReferenceException when used in a winform hybrid application. the reason is that the DragPreviewAdorner uses Application.Current, but this static property is not assigned when running in a winform application. A solution is to change the following method:
to
and pass the current element in SetPreviewElement:
Side note: the class NotifyWorker seems to have the same issue in the OnClientException method... haven't looked at how that could be handled. We aren't using that class.