Hello guys!
i started a WPF application (with vs 2008 sp1) which connects to a web service to get Collection of objects.
I can be contactInfo[]
or groupInfo[]
.
here is my main.xaml.cs
public main()
{
InitializeComponent();
//service.addContactCompleted +=new addContactCompletedEventHandler(addContactCompleted);
service.getContactsCompleted += new getContactsCompletedEventHandler(getContactsCompleted);
fillContents();
}
private void getContactsCompleted(object sender, getContactsCompletedEventArgs e)
{
try
{
//e.Result return contactInfo[]
contactListBox.ItemsSource = e.Result;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
public void fillContents()
{
service.getContactsAsync(session.key, null);
}
and this is my main.xaml
<Window.Resources>
<ObjectDataProvider x:Key="contactInfo" ObjectType="{x:Type serviceAdmin:contactInfo}" />
</Window.Resources>
<Grid>
<ListBox Margin="-146,-124,-143,-118.808" Name="contactListBox" ItemsSource="{Binding Source={StaticResource contactInfo}}" >
<ListBox.ItemTemplate>
<DataTemplate>
<Label Content="{Binding fullName}"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<!--<toolkit:DataGrid Margin="-146,-124,-150,-118.808" Name="contactGrid" ItemsSource="{Binding}"/>-->
</Grid>
this partially works but just that it returns repeated values. it just repeats which ever comes first.I'll like to know what i'm doing wrong here.Can anyone shed some light?? thanks for reading this!!