Skip to main content
Home Forums Silverlight Programming Programming with .NET - General How to Fix 'cannot convert from 'System.Windows.PropertyChangedCallback' to 'System.Windows.PropertyMetadata' ?
4 replies. Latest Post by dbaechtel on August 20, 2008.
(0)
dbaechtel
Member
59 points
207 Posts
08-20-2008 11:24 AM |
I am trying to build Delay's sample from "Lying to the layout system for a good cause [Bringing LayoutTransform to Silverlight 2!]" and I get 7 errors when building with VSTS 2008 SP1. Six of the errors are from code like the following:
private static void ChildChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) { ... } public static readonly DependencyProperty ContentProperty = DependencyProperty.Register( "Child", typeof(FrameworkElement), typeof(LayoutTransformControl), new PropertyMetadata(ChildChanged));
The problem stems from the type conversion of the ChildChanged parameter to PropertyMetadata.This follows then MSDN documentation.
Does anyone know how to fix this?
THANKS MUCH.
Skyrunner
Contributor
2489 points
485 Posts
08-20-2008 11:34 AM |
Replace by
new PropertyMetadata(new PropertyChangedCallback(ChildChanged))
Bill Reiss
4840 points
919 Posts
08-20-2008 11:38 AM |
For a bit of background, this was changed from Beta 1 to Beta 2, the new format is consistent with WPF. The suggestion above is correct.
08-20-2008 11:44 AM |
Skyrunner: Replace by new PropertyMetadata(new PropertyChangedCallback(ChildChanged))
That didn't work.
I changed it to:
public static readonly DependencyProperty ContentProperty = DependencyProperty.Register( "Child", typeof(FrameworkElement), typeof(LayoutTransformControl), new PropertyMetadata(new PropertyChangedCallback(ChildChanged)));
and still getting the same error:
Error 2 Argument '4': cannot convert from 'System.Windows.PropertyChangedCallback' to 'System.Windows.PropertyMetadata'
08-20-2008 12:01 PM |
I'm sorry.
I didn't notice that Delay had the following code defined:
#if SILVERLIGHT using PropertyMetadata = System.Windows.PropertyChangedCallback; #endif
Once I commented that out, the fix worked fine.
THANKS MUCH !!