<Button>
element does have a DataContext
attribute, but my <local:FooView>
does not seem to have any DataContext
attribute. I don't know why.
this.DataContext
from the constructor of MainWindow.xaml.cs
it is null
.
Program.cs
it instantiates something. BuildAvaloniaApp().Start<MainWindow>(() => new MainWindowViewModel());
Ah, so the event listener that updates the view model should be in the view model
sounds about right
var model = new MyModel();
var vm = new MyViewModel (model);
BuildAvaloniaApp().Start<MainWindow>(() => vm);
MainWindowViewModel
needs two constructors. One that takes the MyModel parameter, and one empty constructor for the application to be able to run without exception?
System.Reflection.TargetInvocationException
if I don't have any empty public ctor
<TextBlock Text="{Binding Child1.Text}" />
then it works. If I do Text
instead of Child1.Text
then it don't find it.
<Design.DataContext>
does.
XOpenDisplay