You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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.
The text was updated successfully, but these errors were encountered: