Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReorderListBox doesn't support hybrid Winform applications #30

Open
jonashogstrom opened this issue Sep 12, 2011 · 0 comments
Open

ReorderListBox doesn't support hybrid Winform applications #30

jonashogstrom opened this issue Sep 12, 2011 · 0 comments

Comments

@jonashogstrom
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant