MrHayato
Topic Author
Posts: 36
Joined: 19 Sep 2014, 21:29

DataContextChanged event?

07 Jul 2015, 22:21

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 :/
 
User avatar
sfernandez
Site Admin
Posts: 1912
Joined: 22 Dec 2011, 19:20

Re: DataContextChanged event?

08 Jul 2015, 13:50

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.
 
MrHayato
Topic Author
Posts: 36
Joined: 19 Sep 2014, 21:29

Re: DataContextChanged event?

09 Jul 2015, 00:38

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.
 
User avatar
sfernandez
Site Admin
Posts: 1912
Joined: 22 Dec 2011, 19:20

Re: DataContextChanged event?

10 Jul 2015, 10:55

Do you mean that the OverrideMetadata didn't work when your empty constructor called other constructor?
 
MrHayato
Topic Author
Posts: 36
Joined: 19 Sep 2014, 21:29

Re: DataContextChanged event?

13 Jul 2015, 19:01

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...
 
User avatar
sfernandez
Site Admin
Posts: 1912
Joined: 22 Dec 2011, 19:20

Re: DataContextChanged event?

17 Jul 2015, 13:37

DataContextChanged event will be available in the next 1.2.4 release ;)
 
User avatar
jsantos
Site Admin
Posts: 2904
Joined: 20 Jan 2012, 17:18
Contact:

Re: DataContextChanged event?

11 Aug 2015, 20:10

Fixed in v1.2.4

Who is online

Users browsing this forum: No registered users and 1 guest