Page 1 of 1

DataContext is null [SOLVED]

Posted: Sun Oct 18, 2015 6:41 am
by geoinfonierula
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

Re: DataContext is null

Posted: Mon Oct 19, 2015 9:07 am
by JS-Support @Userware
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

Re: DataContext is null

Posted: Fri Oct 23, 2015 1:13 pm
by JS-Support @Userware
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