views:

34

answers:

1

I have some issues with using databinding in silverlight 4 xaml pages, this is my problem:

I have two data grids:

<sdk:DataGrid x:Name="dgCodeCountry" Height="144" Margin="41,56,39,0"   VerticalAlignment="Top" AutoGenerateColumns="False" ItemsSource="{Binding Collection}" >
  <sdk:DataGrid.Columns>
     <sdk:DataGridTextColumn Binding="{Binding Code}" Header="Code"/>
     <sdk:DataGridTextColumn Binding="{Binding Name}" Header="Name"/>
  </sdk:DataGrid.Columns>
</sdk:DataGrid>


<sdk:DataGrid x:Name="dgStateOfProvince" Height="64" Margin="10,17,10,0" VerticalAlignment="Top">
   <sdk:DataGrid.Columns>

   </sdk:DataGrid.Columns>
</sdk:DataGrid>

First Datagrid dgCodeCountry is filled with data by using Blend4 Sample Data feature. When I select one row from dgCodeCountry, I want that row to appear into dgStateOfProvince. And those datagrids can be anywhere within a usercontrol or xaml page.

How can I manage to do that?

+1  A: 

Bind the ItemsSource of dgStateOfProvince to SelectedItems of dgCodeCountry:

<sdk:DataGrid x:Name="dgStateOfProvince" ItemsSource="{Binding ElementName=dgCodeCountry Path=SelectedItems}">
Ozan
Thanks.In after all I didn't went with this approach, but now I understand the Path=... part :).
Andrei T. Ursan