I have a datagrid which is populated from a web service. I want to fill a form based on the selected item in the datagrid.
This is what I use to set the DataContext (Which is a grid)
private void PublisherSearchList_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
this.PublisherItem.DataContext = (Publisher)PublisherSearchList.SelectedItem;
}
XAML
<Grid Name="PublisherItem" Width="390" Margin="5" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="20"></RowDefinition>
</Grid.RowDefinitions>
<TextBox Name="CompanyName" DataContext="{Binding PublisherName}"
Grid.Column="0" Grid.Row="0"></TextBox>
</Grid>
How can this be done?