1

I created a custom UserControl in my WPF project that has some custom events. The events work with out any problem but there is a small issue with it. In my VS 2015 the control event handlers show "0 references" (CodeLens - this is a VS 2013-15 feature) under the parent window, even though they are hooked to the control in the .xaml file. Generally VS 2015 will show the count and all the references on mouse click (please see the image below).

In the screenshot the resultActionView is my user control. As you can see the event of the control shows "0 references" which is not true. Is there some attributes that needs to be added to the event handlers, or what am I missing?

methods showing "0 references" with CodeLens

An example of event handler declaration in the UserControl:

public event EventHandler<RoutedEventArgs> AviewDeleteSelectionClick;

Does anyone know why the user control event handlers shows "0 references"?

Peter Duniho
  • 68,759
  • 7
  • 102
  • 136
A.G.
  • 304
  • 2
  • 11
  • Please be more specific. What "VS2015 feature" are you referring to? How are you using it? Is this at run-time? Or while editing the code? (Note that while you cannot embed an image, you can still place a link...often someone else with enough reputation will vet the image and inline it.) – Peter Duniho Jul 06 '17 at 01:06
  • Hi Peter, I added a screenshot of the feature. Hopefully some one will vet it. Anyway, the feature I am talking about is VS 2015 feature. On every declaration (property, function etc) it shows the count of references to these functions, properties etc. – A.G. Jul 06 '17 at 15:39
  • In your screenshot are no declared events, I only see methods that look like event handlers. It seems to me like your are talking about the CodeLens feature of VS, am I correct? If so, this feature is AFAIK only working for types, methods and properties, but not for event declarations. Though it works fine for event handlers (as seen in your screenshot). – bassfader Jul 06 '17 at 16:03
  • Hi bassfader, yes the screenshot shows event handler that is hooked in AXML. Yes, thank you! the feature is CodeLens (didn't know the name). Yes it works with event handlers too, but it doesn't with a usercontrol custom event. – A.G. Jul 06 '17 at 16:20
  • Sorry...I recently switched from VS2015 Pro to VS2017 Community. I was under the impression that Microsoft now made the different VS editions 100% feature-compatible, but apparently CodeLens is disabled in the Community edition, so I'm not able to try to reproduce your issue. That said, you should improve this question so it includes a good [mcve] that shows clearly all of the relevant code. Also, you should be careful about your terminology. The _handler_ is the method itself which is subscribed to the event, while the _event_ is the declaration that uses the `event` keyword. – Peter Duniho Jul 06 '17 at 21:28
  • (Just goes to show how much I actually use that feature...I've been using VS2017 Community since my trial install of Pro expired last year, and only just today noticed CodeLens wasn't present when I started looking into your question. :) ) – Peter Duniho Jul 06 '17 at 21:38

0 Answers0