![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
| |
| | #1 (permalink) |
| | 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. |
My System Specs![]() |
| | #2 (permalink) |
| | 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. > > |
My System Specs![]() |
| | #3 (permalink) |
| | 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. >> >> > > |
My System Specs![]() |
| | #4 (permalink) |
| | 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. >>> >>> >> >> > > |
My System Specs![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Using DataContext with WCF services | .NET General | |||
| WPF - Binding IsEnabled property doesnt evaluate until DataContext | .NET General | |||