![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | How to reset datacontext to parent datacontext Hi, I'm trying to suspend binding for the controls of a groupbox. To do that I set its datacontext to null (nothing). That's the first point that surprises me. It works ! I'm surprisedbecause I expected to see the groupbox retrieve its parent datacontext due to dependency property inheritance mechanism. What do I miss there ? But here comes the corollary problem : how to reset the datacontext to the one of its parent ? If I try to force it with (vb code, sorry): mygroupbox.datacontext = ctype(mygroupbox.parent, frameworkelement).datacontext it works... till the parent datacontext changes. The groupbox datacontext is not linked (bound) to it. How to achieve that ? What I want is just the default behavior after all. I tried with DefaultMetadata.DefaultValue but it returns null and so doesn't resolve my problem. I have a working solution by binding the two datacontexts but I guess there's something more direct (an ad-hoc method or something). Thanx in advance. |
| | #2 (permalink) |
| Guest | Re: How to reset datacontext to parent datacontext Ok I think I got it. It seems that the ClearValue method does the trick. Right ? "Pon" <pongla.public@laposte.net> a écrit dans le message de news: uQeMz$o9GHA.4740@TK2MSFTNGP03.phx.gbl... > Hi, > > I'm trying to suspend binding for the controls of a groupbox. To do that I > set its datacontext to null (nothing). > That's the first point that surprises me. It works ! I'm surprised> because I expected to see the groupbox retrieve its parent datacontext due > to dependency property inheritance mechanism. What do I miss there ? > > But here comes the corollary problem : how to reset the datacontext to the > one of its parent ? If I try to force it with (vb code, sorry): > mygroupbox.datacontext = ctype(mygroupbox.parent, > frameworkelement).datacontext > > it works... till the parent datacontext changes. The groupbox datacontext > is not linked (bound) to it. > > > How to achieve that ? What I want is just the default behavior after all. > I tried with DefaultMetadata.DefaultValue but it returns null and so > doesn't resolve my problem. > > I have a working solution by binding the two datacontexts but I guess > there's something more direct (an ad-hoc method or something). > > Thanx in advance. > > |
| | #3 (permalink) |
| Guest | Re: How to reset datacontext to parent datacontext Yup - you got it. There is most definitely a difference between a value which is set (even if to null) and one which is not. As you found, setting a local value - even null - overrides inheritance. And, as you found, ClearValue "unsets" a local value, allowing inheritance to kick in again. -Adam Smith [MS] "Pon" <pongla.public@laposte.net> wrote in message news:OIo59Fp9GHA.3352@TK2MSFTNGP03.phx.gbl... > Ok I think I got it. It seems that the ClearValue method does the trick. > Right ? > > > "Pon" <pongla.public@laposte.net> a écrit dans le message de news: > uQeMz$o9GHA.4740@TK2MSFTNGP03.phx.gbl... >> Hi, >> >> I'm trying to suspend binding for the controls of a groupbox. To do that >> I set its datacontext to null (nothing). >> That's the first point that surprises me. It works ! I'm surprised>> because I expected to see the groupbox retrieve its parent datacontext >> due to dependency property inheritance mechanism. What do I miss there ? >> >> But here comes the corollary problem : how to reset the datacontext to >> the one of its parent ? If I try to force it with (vb code, sorry): >> mygroupbox.datacontext = ctype(mygroupbox.parent, >> frameworkelement).datacontext >> >> it works... till the parent datacontext changes. The groupbox datacontext >> is not linked (bound) to it. >> >> >> How to achieve that ? What I want is just the default behavior after all. >> I tried with DefaultMetadata.DefaultValue but it returns null and so >> doesn't resolve my problem. >> >> I have a working solution by binding the two datacontexts but I guess >> there's something more direct (an ad-hoc method or something). >> >> Thanx in advance. >> >> > > |
| | #4 (permalink) |
| Guest | Re: How to reset datacontext to parent datacontext Thanx for confirming. "Adam Smith [MS]" <Adam.Smith@microsoft.com> a écrit dans le message de news: OGQRXU49GHA.748@TK2MSFTNGP02.phx.gbl... > Yup - you got it. There is most definitely a difference between a value > which is set (even if to null) and one which is not. As you found, > setting a local value - even null - overrides inheritance. And, as you > found, ClearValue "unsets" a local value, allowing inheritance to kick in > again. > > -Adam Smith [MS] > > "Pon" <pongla.public@laposte.net> wrote in message > news:OIo59Fp9GHA.3352@TK2MSFTNGP03.phx.gbl... >> Ok I think I got it. It seems that the ClearValue method does the trick. >> Right ? >> >> >> "Pon" <pongla.public@laposte.net> a écrit dans le message de news: >> uQeMz$o9GHA.4740@TK2MSFTNGP03.phx.gbl... >>> Hi, >>> >>> I'm trying to suspend binding for the controls of a groupbox. To do that >>> I set its datacontext to null (nothing). >>> That's the first point that surprises me. It works ! I'm surprised>>> because I expected to see the groupbox retrieve its parent datacontext >>> due to dependency property inheritance mechanism. What do I miss there ? >>> >>> But here comes the corollary problem : how to reset the datacontext to >>> the one of its parent ? If I try to force it with (vb code, sorry): >>> mygroupbox.datacontext = ctype(mygroupbox.parent, >>> frameworkelement).datacontext >>> >>> it works... till the parent datacontext changes. The groupbox >>> datacontext is not linked (bound) to it. >>> >>> >>> How to achieve that ? What I want is just the default behavior after >>> all. I tried with DefaultMetadata.DefaultValue but it returns null and >>> so doesn't resolve my problem. >>> >>> I have a working solution by binding the two datacontexts but I guess >>> there's something more direct (an ad-hoc method or something). >>> >>> Thanx in advance. >>> >>> >> >> > > |
| |
| |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Using DataContext with WCF services | Ragesh Krishna | .NET General | 1 | 2 Weeks Ago 02:27 AM |
| WPF - Binding IsEnabled property doesnt evaluate until DataContext | Todd Beaulieu | .NET General | 1 | 03-06-2008 09:52 AM |
| About DataContext | howen | Avalon | 0 | 05-22-2007 05:20 AM |
| using DataContext to bind from Page linked by Frame | buzzweetman@gmail.com | Avalon | 1 | 04-24-2007 01:27 AM |
| Is binding a datacontext to a CLR object correct ? | Pon | Avalon | 2 | 03-25-2007 05:31 PM |