Page 1 of 1

DataContextChanged event?

Posted: 07 Jul 2015, 22:21
by MrHayato
Is there no DataContextChanged event? I am currently using a workaround by overriding the metadata for DataContextProperty as follows:

DataContextProperty.OverrideMetadata(typeof(MyView), new FrameworkPropertyMetadata(null, (o, args) => 
    {
        /* Do stuff when data context changes */
    }));
But I'm not sure if there are side effects of doing this?

Also, the forums should allow us to search terms longer than 14 characters... I couldn't do a search for DataContextChanged because it's too long :/

Re: DataContextChanged event?

Posted: 08 Jul 2015, 13:50
by sfernandez
Is there no DataContextChanged event?
No, but we can add it for the next release.
I am currently using a workaround by overriding the metadata for DataContextProperty as follows:

DataContextProperty.OverrideMetadata(typeof(MyView), new FrameworkPropertyMetadata(null, (o, args) => 
    {
        /* Do stuff when data context changes */
    }));
But I'm not sure if there are side effects of doing this?
Your solution is fine and surely will help others until we expose the event, thanks.
Also, the forums should allow us to search terms longer than 14 characters... I couldn't do a search for DataContextChanged because it's too long :/
Fixed, we extended indexing to 32 character per term. Thanks for pointing out this issue.

Re: DataContextChanged event?

Posted: 09 Jul 2015, 00:38
by MrHayato
It didn't work before. I wonder if it was because I was using the empty constructor to call my other constructor using
public MyClass() : this(null) {
}
Leaving just an empty constructor though does seem to do the trick.

Re: DataContextChanged event?

Posted: 10 Jul 2015, 10:55
by sfernandez
Do you mean that the OverrideMetadata didn't work when your empty constructor called other constructor?

Re: DataContextChanged event?

Posted: 13 Jul 2015, 19:01
by MrHayato
Sorry, I replied to this thread mistakenly. It was actually meant to be in response to this other thread:
viewtopic.php?f=3&t=747

I had too many tabs open...

Re: DataContextChanged event?

Posted: 17 Jul 2015, 13:37
by sfernandez
DataContextChanged event will be available in the next 1.2.4 release ;)

Re: DataContextChanged event?

Posted: 11 Aug 2015, 20:10
by jsantos
Fixed in v1.2.4