Reputation: 883
I want to change the source in XAML to another object source. For example:
Caveat: I am implementing MVVM, so the "Model A" is assigned to the Window as a VM DataSource, XAML knows nothing about it.
View.DataSource = MyViewModel (that contains "Model A")
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 WINDOW> 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? Can someone point me in the right direction?
Upvotes: 0
Views: 1520
Reputation: 8829
<Label Content="{Binding RelativeSource={RelativeSource FindAncestor,
AncestorType={x:Type Window}}, Path=Total}"/>
Upvotes: 2