I have a listbox and as ItemsSource I give it an IList .
In this object exists another object with name {User} and I am trying to Bind the property {Username} onto a textBlock.
I tried something like this but with no luck
<TextBlock x:Name="usernamtTBL" Text="{Binding 'User.Username'}"/>
This is the full XAML code of listbox
<ListBox Height="275" x:Name="NewsFeedLB" Canvas.Left="8" Canvas.Top="8" Width="427" Background="White">
<ListBox.ItemTemplate>
<DataTemplate>
<Canvas Height="57" Width="265" d:DesignWidth="265" d:DesignHeight="155">
<Border BorderBrush="Black" BorderThickness="1" Height="35" Canvas.Left="8" Canvas.Top="8" Width="48">
<Image x:Name="thumbIMG" Margin="7"/>
</Border>
<TextBlock x:Name="usernamtTBL" Text="{Binding 'User.Username'}" Height="12" Canvas.Left="71" TextWrapping="Wrap" Canvas.Top="8" Width="180"/>
<TextBlock x:Name="statusTBL" Text="{Binding 'Text'}" Height="12" Canvas.Left="71" TextWrapping="Wrap" Canvas.Top="24" Width="180"/>
</Canvas>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
and this is from codebehind
private void MainPage_Loaded(object sender, System.Windows.RoutedEventArgs e) {
var newsFeedWcfClient = new NewsFeedWCFClient();
newsFeedWcfClient.GetNewsFeedItemsCompleted += new EventHandler<GetNewsFeedItemsCompletedEventArgs>(newsFeedWcfClient_GetNewsFeedItemsCompleted);
newsFeedWcfClient.GetNewsFeedItemsAsync();
}
void newsFeedWcfClient_GetNewsFeedItemsCompleted(object sender, GetNewsFeedItemsCompletedEventArgs e) {
var source = (IList<NewsFeed>)e.Result;
NewsFeedLB.ItemsSource = source;
}
Could someone help me solve this issue?
Thanks