1

I have a navigation plugin which I want to extend to allow support for context navigation. I've got everything I need except for the NavigationOptions instance. In my INavigateFromHereProvider I get called with an IDataContext so can create the NavigationOptions from this using the NavigationOptions.FromDataContext method. Great.

In my context action I don't get called with a IDataContext, I get given a ICSharpContextActionDataProvider during construction. I can get my IDeclaredElement from this to base my navigation decision on, but I'm not sure how to create my NavigationOptions instance. It feels like I should be using NavigationOptions.FromWindowContext but I seems to need a PopupWindowContextSource and I don't know where to get one of these from.

So where can I get a relevant PopupWindowContextSource to create my NavigationOptions from?

Community
  • 1
  • 1
Sam Holder
  • 32,535
  • 13
  • 101
  • 181

2 Answers2

1

Ah, discovered the answer (well, an answer).

I can use this:

 var popupWindowContextSource = solution.GetComponent<MainWindowPopupWindowContext>().Source;

I'm not sure if this is the most appropriate thing to use, but it seems to work.

Sam Holder
  • 32,535
  • 13
  • 101
  • 181
0

You might be better off using NavigationOptions.FromDataContext. This will pull a window context from the IDataContext that you've already got. This should give you a popup window context that's appropriate to where you've been invoked from - anchored to the editor window, or the tree view, or whatever. Using the MainWindowPopupContext will give you a context that's based on the main Visual Studio window, which will likely work and be fine, but might not be the most relevant.

citizenmatt
  • 18,085
  • 5
  • 55
  • 60
  • I don't have a `IDataContext` at this point. I'm adding support for doing the navigation via Alt-Enter (a context action) so in my `IsAvailable(IUserDataHolder cache)` method I only have access to the `ICSharpContextActionDataProvider ` I was given in the constructor – Sam Holder Jul 07 '15 at 10:03
  • It's in this method that I want to get a popupwindowcontextsource – Sam Holder Jul 07 '15 at 10:54
  • Oops. Misread the question. I think using `MainWindowPopupContext` is fine, then, or you could even create your own that derives from `PopupWindowContext`. – citizenmatt Jul 07 '15 at 13:50