PickContext doesn't work correctly in a wpf application

PickContext is needed to set a RhinoView before using .But for a viewport in a wpf application using Rhino.Inside, the ParentView property is Null. I use ActiveView to replace it . But another problem comes up. When the viewport is parallel , it works. When the viewport is perspective , the pickcontext dosent work correctly when magnify the viewport . Here is my code, “Viewport.Magnify(magnificationFactor, false)” is to keep the camera length. Once I do so, it work incorrectly.

 protected override void OnMouseWheel(MouseEventArgs e)
        {
            if (HostUtils.RunningInRhino)
            {
                double magnificationFactor = 1.0 / ViewSettings.ZoomScale;
                magnificationFactor *= magnificationFactor;
                magnificationFactor *= (e.Delta < 0) ? -1.0 : 1.0;
                if (magnificationFactor < 0.0)
                {
                    magnificationFactor = -1.0 / magnificationFactor;
                }
                Viewport.Magnify(magnificationFactor, true);
            }
            Refresh();
        }
 {
                    PickStyle = PickStyle.PointPick,
                    PickLine = frustumLine,
                    View = RhinoDoc.ActiveDoc.Views.ActiveView,
                    PickMode = PickMode.Shaded
                })
                {
                    var pickTransform = vp.GetPickTransform(e.Location);
                    pick.SetPickTransform(pickTransform);
}

It works correctly in parallel view.

Help Please…

Note that it’s Thanksgiving in the US and lots of people will be gone until Monday…
-wim

Finally I solved with a extremely stupid way.I construct a view same as the viewport in my wpf application and used pinvoke to hide the rhinoview behind my application.Then I can use the view in pickcontext . Maybe pickcontext is not perfect now…

@wim @dale Any other smarter solution? Right now the RhinoWindows.dll seems unsatisfying…