简体   繁体   中英

Visual Studio 2013 Extending Solution Explorer Filter

I'm trying to create a VsPackage with a custom filter for the solution explorer. I followed the walkthrough on https://msdn.microsoft.com/en-us/library/hh966591.aspx to the latter, I see the button and I can click it but the filter is never applied. And I can't even debug it because no single method in the filter class is ever called. Does anyone have experience writing a custom filter or maybe just had the same problem?

The command handler doesn't need to do anything, in fact you can remove the command binding, the filter is bound through the Guid/Id parameters of the SolutionTreeFilterProvider(guid, id) attribute.

Your case seems a bug of VS 2013 because in VS 2012 it works.

I have opened a bug report in MS Connect: https://connect.microsoft.com/VisualStudio/feedback/details/1131606

UPDATE: it's a bug in the documentation sample of VS 2013 that it's correct in VS 2012:

The first parameter should be of type SVsServiceProvider and not IServiceProvider:

  [ImportingConstructor]
  public FileNameFilterProvider(**SVsServiceProvider** serviceProvider, IVsHierarchyItemCollectionProvider hierarchyCollectionProvider)
  {
     ServiceProvider = serviceProvider;
     this.HierarchyCollectionProvider = hierarchyCollectionProvider;
  }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM