views:

13

answers:

1

Hi.

I've the page:

    <view:PhoneApplicationPageBase
    x:Class="Exadel.CCHMobile.View.NewsView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:view="clr-namespace:Exadel.CCHMobile.View"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d" Height="768" Width="480"
    shell:SystemTray.IsVisible="True">

    <view:PhoneApplicationPageBase.DataContext>
        <Binding Path="News" Source="{StaticResource Locator}" />
    </view:PhoneApplicationPageBase.DataContext>

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent">

        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <StackPanel Grid.Row="0">
            <TextBlock Text="{Binding Path=TrackerTitle}" Style="{StaticResource PhoneTextNormalStyle}"/>
        </StackPanel>

        <ListBox Grid.Row="1" ItemsSource="{Binding Path=News}" VerticalAlignment="Stretch">
            <DataTemplate>
<TextBlock Grid.Row="0" Grid.Column="0" Text="{Binding Title}"/>
            </DataTemplate>
        </ListBox>
    </Grid>

</view:PhoneApplicationPageBase>

My Model has property TrackerTitle, is binds ok. I have a News collection also in the model. I can't bind the Title property of News entity to the TextBlock. What is wrong? Thank you.

+1  A: 

Here

<ListBox Grid.Row="1" ItemsSource="{Binding Path=News}" VerticalAlignment="Stretch">
     <DataTemplate>
         <TextBlock Grid.Row="0" Grid.Column="0" Text="{Binding Title}"/>
     </DataTemplate>
</ListBox>

The DataTemplate is hanging in the mid-air. It should be inside ItemTemplate.

Also, is your collection ObservableCollection? or does it subscribes Property change notification ?

Avatar