DataContext is null [SOLVED]

Please report bugs here. If you are unsure whether something is a bug or an expected behavior, please post it on the "Technical Support" forum instead, and wait for a moderator to handle/move the post.
geoinfonierula
Posts: 6
Joined: Fri Oct 16, 2015 11:49 am

DataContext is null [SOLVED]

Postby geoinfonierula » Sun Oct 18, 2015 6:41 am

Hi

I have a little page containing a Grid and a TextBlock inside the Grid. I want to set the text in the TextBlock via DataBinding MVVM-Style. In CodeBind of the Page I set ist DataContext using this.DataContext = new MyViewModel(); (The ViewModel is implementing INotifyPropertyChanged)

Unfortunately Binding of the TextBlocks Text is not working and in Debugger I see, that the DataContext is available on the Page, the Grid but not on the TextBlock.

Is this a bug or a Feature? How can I access the DataContext of the Page from the TextBlock? If it is a bug, is there a Workaround?

Best Regards


Bernd

JS-Support @Userware
Site Admin
Posts: 1043
Joined: Tue Apr 08, 2014 3:42 pm

Re: DataContext is null

Postby JS-Support @Userware » Mon Oct 19, 2015 9:07 am

Hi Bernd,

What you are describing is supposed to work properly.

We are trying to reproduce it.

Can you please create a new C#/XAML for HTML5 "Empty" project where you reproduce the issue with very minimal code, and then send us the project by compressing it into a ZIP archive and attaching it to this forum thread?

This way we will fix it very quickly.

Thank you very much,
Regards,
JS-Support

JS-Support @Userware
Site Admin
Posts: 1043
Joined: Tue Apr 08, 2014 3:42 pm

Re: DataContext is null

Postby JS-Support @Userware » Fri Oct 23, 2015 1:13 pm

Hi Bernd,

We have been able to reproduce the issue.

It has been fixed in Beta 5.1, available at:
http://forums.cshtml5.com/viewtopic.php?f=2&t=192

Please confirm that it fixed the issue for you.

Thank you and regards,
JS-Support


Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 2 guests

 

 

cron