Incorrect "Dependency property missing" warning in Xaml

Since installing Resharper I've started to notice "Dependency property
missing" errors in my Xaml for attached behaviors.

Here's a simplified repro. Generate a new default WPF application project
and...

=== Add new TestBehavior.cs:

using System.Windows;

namespace WpfApplication7
{
     public static class TestBehavior
     {
          public static readonly DependencyProperty Foo =
DependencyProperty.RegisterAttached(
               "Foo", typeof(bool), typeof(TestBehavior));
          public static bool GetFoo(DependencyObject dependencyObject)
               { return (bool)dependencyObject.GetValue(Foo); }
          public static void SetFoo(DependencyObject dependencyObject, bool value)
               { dependencyObject.SetValue(Foo, value); }
     }
}

=== Edit existing MainWindow.xaml:




The problem occurs in MainWindow.xaml. On my system, the "Foo" in the second
to the last line of MainWindow.xaml is flagged as an error with a squiggly
red line. The tooltip says "Dependency property missing". Yet it exists and
the app builds fine.

Scott


3 comments
Comment actions Permalink

Here's the XML that got filtered out of the newsrc post.

=== Edit existing MainWindow.xaml:

<Window x:Class="WpfApplication7.MainWindow"
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
     xmlns:local="clr-namespace:WpfApplication7"
     Title="MainWindow" Height="350" Width="525">

     <Grid local:TestBehavior.Foo="true"/>
</Window>

0
Comment actions Permalink

WPF conventions imply that dependency properties have the name FooProperty, whereas you declared Foo. That should be the problem here.

0
Comment actions Permalink

Yes, that was the issue, thank you.

0

Please sign in to leave a comment.