Can I change the binding source to another source in XAML?
Posted
by No hay Problema
on Stack Overflow
See other posts from Stack Overflow
or by No hay Problema
Published on 2010-04-07T09:10:57Z
Indexed on
2010/04/07
9:13 UTC
Read the original article
Hit count: 266
Hi guys,
I want to do a very simple thing, can you point me on the right direction?
I want to change the source in XAML to another object source, let me put you an example:
- I have a Listview, bound to a "Model A", it has many properties, but one is called "Total". This property is not shown on the View
- Each ListviewItem has its own source (ItemsSource), BUT, one of the fields should show "Total" from "Model A"
Caveat: I am implementing MVVM, so the "Model A" is assigned as a VM DataSource, XAML knows nothing about it.
So, in my perfect world the XAML should look like this:
<GridViewColumn Header="Total" Width="150">
<GridViewColumn.CellTemplate>
<DataTemplate>
<Label Content="{Binding Source=<The source of LISTVIEW> Path=Total}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
I have tried RelativeSource but that points me to the XAML object, I want the source of it, is it possible?
Thanks
© Stack Overflow or respective owner