When using ReactiveUI, one can set the bindings in xaml ...
<TextBox x:Name="SomeProperty" Text="{Binding SomeProperty}" />
or in code behind
this.Bind(ViewModel, vm.SomeProperty, v => v.SomeProperty.Text);
There seem to be certain circumstances (such as binding to child objects in a ListBox) where using the .xaml
option seems the only way to go
eg
<ListView>
<ListView.ItemTemplate>
<DataTemplate DataType="ListViewItem">
<TextBox Text="{Binding ChildViewModelProperty}" />
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
Am I wrong to use {Binding }
or can i mix and match .xaml
and code behind
as i see fit?!
this.Bind
syntax since it's much more powerful and compile time checked, and resort to{Binding}
when it is necessary (like in your example). – Makkah