Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
DependencyProperty ClearValue
Message
From
16/02/2009 14:57:21
 
 
General information
Forum:
ASP.NET
Category:
Windows Presentation Foundation (WPF)
Environment versions
Environment:
C# 3.0
Miscellaneous
Thread ID:
01381612
Message ID:
01382184
Views:
55
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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform