This example is a admittedly a little contrived but I am doing something similar. Let's say I have the following simple classes:
public class Person
{
public string Name { get; set; }
public List<Alias> Aliases { get; set; }
}
public class Alias
{
public string AliasName { get; set; }
}
And let's say that I have Xaml with a LayoutRoot grid, and a DataGrid where I want to access the Name property within the DataGrid instead of the Aliases properties like in the second column here:
<Grid x:Name="LayoutRoot" DataContext="PersonInstance">
<DataGrid ItemsSource="{Binding Aliases}">
<DataGrid.Columns>
<data:DataGridTextColumn Header="AliasName" Binding="{Binding AliasName, Mode=TwoWay}"/>
<data:DataGridTextColumn Header="Name" Binding="{Binding ../Name, Mode=TwoWay}"/>
</DataGrid.Columns>
</DataGrid>
</Grid>
That is intuitively how I would attempt to bind the name, but needless to say that looks stupid. Is there something like that when specifying a path, or are you forced to get a relative source up to the LayoutRoot data context. If you have to, what's the most efficient way?