MVVM Binding
I want to pass data to view model and store in list and show in collection View
i am Binding in the Xaml.cs And Xmal I am getting this Issue no datacontex found for binding
2 Replies
Is that a design time error?
Set the
DataContext
in XAML instead of setting it in C# in the constructor.
First add the Namespace
, like so
Then use it on the Window or Page like so
If this is plain WPF, as an alternative, you can set the DataContext for the DesignTime to get rid of the Warning
. Note: It's not an Error
, just the designer grumbling.
To do so, add this attribute to the Window
tag:
Note: It's actually more cleaner to set the DataContext via XAML and the latter will only set it for designtime.