Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
DependencyProperty ClearValue
Message
De
16/02/2009 14:57:21
 
 
À
16/02/2009 05:23:11
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:
01382184
Vues:
54
I haven't played with Property Value Inheritance at all. In fact I thought you were talking about class inheritance and it was confusing the hell out of me. <g>

Now that I figured that out I understand what your doing a lot better. lol

But I'm still a bit confused I think.

The one thing I don't see from your code is how you plan to init the DefaultValue. I think that's my biggest remaining confusion.

Is what you are trying to do here to make it so that the child cannot be unlocked if the parent is locked?

If the answer is yes, then I'm going to have to rethink the rest of this.

>Can't make it readonly because (a) I need to be able to set it to true and (b) I need inheritance.
>IAC, if it's just being set in (my) code behind then there's no problem since I can always route through the wrapper.

But if you are only setting it from your code... it can be set to true false or whatever and I "think" it would still inherit. If this values is not supposed to be settable from XAML I would try to make them readonly. Readonly can be a bit harry to code, but it is doable and I believe it prevents the problems you were trying to avoid.

>Main problem with that is that it could confuse other developers in that after
x.ContentIsLocked=true;
>x.ContentIsLocked = false;
>the property would actually be true with no indication that the expected value wasn't taken. The other alternative would be simply to return false from the validation callback if false is passed in (thus generating an exception). And the problem with that is that is is not instance specific so if a false value was ever acceptable in a specific case I would have no way of detecting it - whereas I could make the coerce value code conditional.....Arrrrrgggg

This is why I feel you should use two properties. A Locked and a CanUnlock (or what ever you want to call it) property. It makes the behavior much clearer to the end user. And it allows for a test to see if unlocking is an option. But this also depends on the answer above, so I'll wait to see what the answer is.

I'm not certain that you can't implement Property Value Inheritance with a DP. But if I understand your scenario an attached DP makes way more sense.

HTH
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform