1

I wrote a custom control in WPF XAML using Visual Studio 2015. I wrote a little test application for it and, once I got it working, copied it to another application. There I got errors in my XAML. In this code:

<Canvas.Triggers>
    <EventTrigger RoutedEvent="MouseEnter" SourceName="imgCenter">
        <BeginStoryboard Name="GlowAnimation">
            <Storyboard>
                <DoubleAnimation 
                    Storyboard.TargetName="cirHighlight"
                    Storyboard.TargetProperty="Opacity"
                    From="0"
                    To="1"
                    Duration="0:0:0.5" />
            </Storyboard>
        </BeginStoryboard>
    </EventTrigger>
    ...

I get an error on MouseEnter. It appears red and mousing over it displays the message:

EventTrigger.RoutedEvent
Cannot resolve symbol 'MouseEnter'

I have several triggers, and all of them give me the red text and error message on the RoutedEvent.

That's strange, but even stranger is that it actually compiles and works: the triggers work and operate as expected. But it's really frustrating that they appear as errors in the editor. I'm new to animation in WPF and rely on the IDE to tell me if I'm doing something wrong. So for now, the IDE thinks I'm screwing up, but the framework executes it fine.

Any idea what's going on and how to resolve it?

EDIT

I forgot to mention that I'm using ReSharper. It appears this may be the source of the problem.

EDIT

ReSharper is definitely the problem. I loaded my solution into Visual Studio on a workstation that doesn't have ReSharper and, sure enough, no errors.

Frecklefoot
  • 1,660
  • 2
  • 21
  • 52
  • 1
    It works for me.But this may help you.http://stackoverflow.com/questions/25549826/resharper-wpf-error-cannot-resolve-symbol-myvariable-due-to-unknown-datacont – FreeMan Sep 20 '16 at 16:23
  • Possible duplicate of [Resharper "can not resolve symbol" even when project builds](http://stackoverflow.com/questions/15713167/resharper-can-not-resolve-symbol-even-when-project-builds) – Dour High Arch Sep 21 '16 at 22:00

2 Answers2

2

Try below:

<EventTrigger RoutedEvent="MouseEnter" SourceName="imgCenter">
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard>
 <DoubleAnimation 
                Storyboard.TargetName="cirHighlight"
                Storyboard.TargetProperty="Opacity"
                From="0"
                To="1"
                Duration="0:0:0.5" />
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
maulik kansara
  • 1,087
  • 6
  • 21
2

I went to the other posts as @maulik and @FreeMan suggested. The solutions there didn't work, but it got me to look at something closer. Clicking the lightbulb next to the offending line (is that ReShaper or Visual Studio that does that?), it suggested I change my formatting from:

<EventTrigger RoutedEvent="MouseEnter" SourceName="imgCenter">

To this:

<EventTrigger SourceName="imgCenter">
    <EventTrigger.RoutedEvent>MouseEnter</EventTrigger.RoutedEvent>

Even though they are only syntactically different, the second version doesn't show an error. I'm not sure I really like this solution--I may have to just uninstall and reinstall ReSharper to keep the same syntax--but it did get rid of the error.

Frecklefoot
  • 1,660
  • 2
  • 21
  • 52