web services - ListBox not populating on data bind in Silverlight 2 -
So I'm trying to learn Silverlight, so I have created a simple demo app that pulls my home feed and Displays items in the list.
I have a defined definition:
& lt; ListBox x: name = "lstItems" margin = "5,61,5,5" grid Row = "1" & gt; & Lt; ListBox.ItemTemplate & gt; & Lt; DataTemplate & gt; & Lt; Stackpayel margin = "8,8,43,8" & gt; & Lt; Text block text = "{binding title}" /> & Lt; / StackPanel & gt; & Lt; / DataTemplate & gt; & Lt; /ListBox.ItemTemplate> & Lt; / ListBox & gt; which is being populated by a web service call
Private Zero Loginbetton_link (Object Sender, RoutedEventArgs e) {FriendFeedServiceClient client = new FriendFeedServiceClient (); Client.GetHomeCompleted + = New EventHeader & lt; GetHomeCompletedEventArgs & gt; (Client_GetHomeCompleted); Client.GetHomeAsync (FfUsername.Text, FfApiKey.Password); } Void client_GetHomeCompleted (object sender, GetHomeCompletedEventArgs e) {lstItems.DataContext = e.Result; } FriendFeedServiceClient is making a call on a local website that proxies a request for the actual FriendFeed webservice.
Service call works fine, item is returned, if I call debug lstItems.DataContext property is filled in a list of items with data in them, but the list Nothing displays, it's always empty. Am I missing something?
You need to bind your listbox, something like that
& lt; List Box X: Name = "lstItems" margin = "5,61,5,5" grid Rau = "1" item source = "{binding}" & gt;
and then bound to the path title of TextBlock should work. You are setting DataContext, which in a way gives an indication that you are probably a compelling custom object, you have to make the choice of
YourCustomObject obj = (YourCustomObject) e.GetResult For casting your custom object e.GetResult, something has tried, LstItems.DataContext = obj;
HH
Comments
Post a Comment