Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
DependencyProperty ClearValue
Message
De
14/02/2009 13:21:44
 
 
À
13/02/2009 14:02:30
Information générale
Forum:
ASP.NET
Catégorie:
Windows Presentation Foundation (WPF)
Versions des environnements
Environment:
C# 3.0
Divers
Thread ID:
01381612
Message ID:
01381793
Vues:
32
>>Hi,
>>I've built a bool DependencyProperty (with the standard property wrapper) that implements inheritance.
>>If I set the property wrapper to 'true' I want it to set this on the DependencyProperty
>>But when I set it to 'false' I want to execute the .ClearValue() method instead.
>>I know I can't do this in the wrapper, or in the ValidateValueCallback - but can I do it in the CoerceValueCallback?
>>Or is there another way (maybe a wrapper for the wrapper?)
>>
>>Best,
>>Viv
>
>I've never actually used those functions... But so far in WPF when I can't do something like that from where I am, I can usually do it with a delegate.
>
>If that won't work, maybe you could post a little code that shows what you are trying to do.
Hi,
For now I've just used the wrapper to control this:
public class ShapeCanvas3: Canvas
       public static DependencyProperty ContentIsLockedProperty;

        static ShapeCanvas3()
        {
            FrameworkPropertyMetadata p = new FrameworkPropertyMetadata();
            p.Inherits = true;
            ContentIsLockedProperty = DependencyProperty.Register("ContentIsLocked", typeof(bool), typeof(ShapeCanvas3), p);
        }

        public bool ContentIsLocked
        {
            set
            {
                if (value)
                    SetValue(ContentIsLockedProperty, value);
                else
                    this.ClearValue(ContentIsLockedProperty);
            }
            get { return (bool)GetValue(ContentIsLockedProperty); }
        }
}
This works OK for me at the moment but ideally I'd like to prevent the DependencyProperty being set to false in XAML etc. I'll experiment with trying to do something in either the Valid or CoerceValue callback but, from the docs, it doesn't seem doable....
Regards,
Viv
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform