In Silverlight 3, I am tring to produce a basic, populated datagrid, but the datagrid is displaying 4 empty rows.
The code snippets for the page.xaml and page.xaml.cs are below.
I think the data is correctly contained in e.Results, because when I step through the codebehind, the Web service is returning the List correctly populated, e.Results shows a count of 4, and the datagrid displays four empty rows. (I have not yet figured out how to see what exactly is in e.Results)
Here is the relevant code in page.xaml.cs:
void Page_Loaded(object sender, RoutedEventArgs e)
{
Service1Client service = new Service1Client();
service.GetAccountsCompleted += new
EventHandler<GetAccountsCompletedEventArgs>(service_GetAccountsCompleted );
service.GetAccountsAsync();
}
void service_GetAccountsCompleted(object sender, GetAccountsCompletedEventArgs e)
{
this.grdData.ItemsSource = e.Result;
}
Here is the xaml definition of the datagrid:
<UserControl xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data" x:Class="BegSilver.Page"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="400" Height="300">
<Grid x:Name="LayoutRoot" Background="White">
<data:DataGrid x:Name="grdData" Margin="15" AutoGenerateColumns="False">
<data:DataGrid.Columns>
<data:DataGridTextColumn Binding="{Binding acpk}" Header="acpk"></data:DataGridTextColumn>
<data:DataGridTextColumn Binding="{Binding acctnumber}" Header="acctnumber"></data:DataGridTextColumn>
<data:DataGridTextColumn Binding="{Binding name}" Header="name"></data:DataGridTextColumn>
<data:DataGridTextColumn Binding="{Binding type}" Header="type"></data:DataGridTextColumn>
</data:DataGrid.Columns>
</data:DataGrid>
</Grid>
</UserControl>
Any help would be greatly appreciated, Mike Thomas