Hi, I'm building a Silverlight app using RIA Services. I want to implement a master/detail behaviour. The trick here is that the "detail" grid can not be filled directly with the "SelectedItem" property of the master grid, and what I have to do is get one of the fields from the master grid and use it as a parameter to the DataService. How would the binding be?
This is the code of the parametrized query:
public Usuarios GetUserFromId(int id)
{
return this.ObjectContext.Usuarios.Where(u => u.ID == id).First();
}
And these are the sources on the XAML:
<riaControls:DomainDataSource x:Name="DomainDataSourceRaceTrackGetUsersWithRole" AutoLoad="True" QueryName="GetUsersWithRoleQuery" LoadSize="20">
<riaControls:DomainDataSource.DomainContext>
<App:DomainServiceRaceTrack></App:DomainServiceRaceTrack>
</riaControls:DomainDataSource.DomainContext>
</riaControls:DomainDataSource>
<riaControls:DomainDataSource x:Name="DomainDataSourceRaceTrackGetUserById" AutoLoad="True" QueryName="GetUserFromId">
<riaControls:DomainDataSource.DomainContext>
<App:DomainServiceRaceTrack></App:DomainServiceRaceTrack>
</riaControls:DomainDataSource.DomainContext>
</riaControls:DomainDataSource>
Here's how I bind the master grid:
<data:DataGrid x:Name="DataGridUsers" AutoGenerateColumns="False" ItemsSource="{Binding Data, ElementName=DomainDataSourceRaceTrackGetUsersWithRole}">
And then on SelectedItemChanged I need to populate the Detail grid, but the binding I use doesn't work:
<dataControls:DataForm x:Name="dataForm1" Height="393" Width="331"
VerticalAlignment="Top"
Header="User Details"
CurrentItem="{Binding DataGridUsers.SelectedItem.Id, ElementName=DomainDataSourceRaceTrackGetUserById}"
HorizontalAlignment="Left" >
<dataControls:DataForm.EditTemplate>
Anyone knows what I'm doing wrong? I'd like to use XAML instead of codebehind.
Thanks!