Browse Source

XamlParser now supports attached property used on a derived class.

pull/442/head
gumme 12 years ago
parent
commit
85a4c4600b
  1. 20
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/XamlDom/ExampleService.cs
  2. 13
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/XamlDom/SimpleLoadTests.cs
  3. 5
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlParser.cs

20
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/XamlDom/ExampleService.cs

@ -67,5 +67,25 @@ namespace ICSharpCode.WpfDesign.Tests.XamlDom @@ -67,5 +67,25 @@ namespace ICSharpCode.WpfDesign.Tests.XamlDom
// TODO: add this test, check for correct setting of NameScope
//TestHelperLog.Log("ExampleDependencyObject.OnPropertyChanged " + e.Property.Name);
}
public static readonly DependencyProperty ExampleProperty = DependencyProperty.RegisterAttached(
"Example", typeof(string), typeof(ExampleDependencyObject)
);
public static string GetExample(DependencyObject element)
{
TestHelperLog.Log("ExampleDependencyObject.GetExample");
return (string)element.GetValue(ExampleProperty);
}
public static void SetExample(DependencyObject element, string value)
{
TestHelperLog.Log("ExampleDependencyObject.SetExample");
element.SetValue(ExampleProperty, value);
}
}
public class DerivedExampleDependencyObject : ExampleDependencyObject
{
}
}

13
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/XamlDom/SimpleLoadTests.cs

@ -418,5 +418,18 @@ namespace ICSharpCode.WpfDesign.Tests.XamlDom @@ -418,5 +418,18 @@ namespace ICSharpCode.WpfDesign.Tests.XamlDom
</t:ExampleClass>
");
}
[Test]
public void UsingAttachedPropertyOnDerivedClass()
{
TestLoading(@"
<Window
xmlns=""http://schemas.microsoft.com/netfx/2007/xaml/presentation""
xmlns:t=""" + XamlTypeFinderTests.XamlDomTestsNamespace + @"""
xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml""
t:DerivedExampleDependencyObject.Example=""test"">
</Window>
");
}
}
}

5
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlParser.cs

@ -478,6 +478,11 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -478,6 +478,11 @@ namespace ICSharpCode.WpfDesign.XamlDom
return new XamlDependencyPropertyInfo((DependencyProperty)field.GetValue(null), true);
}
}
if (elementType.BaseType != null) {
return TryFindAttachedProperty(elementType.BaseType, propertyName);
}
return null;
}

Loading…
Cancel
Save