Элементы ListBox кликабельны, но не видны WP7

Я создаю приложение для Windows Phone 7.
У меня есть строковые элементы, которые добавляются в ListBox.
Когда я запускаю приложение, элементы в ListBox кликабельны, но я не вижу их.
Они установлены видимыми и белыми (черный фон).

Кто-нибудь знает, что может быть причиной этого?

Вот мой код ListBox:

<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0" ShowGridLines="False">
        <StackPanel>
            <StackPanel Orientation="Horizontal">
                <Button Content="i" Height="72" HorizontalAlignment="Left" Margin="0,0,0,0" Name="informationButton" VerticalAlignment="Top" Width="70" FontFamily="Georgia" DataContext="{Binding}" Click="informationButton_Click" />
                <TextBox Height="72" HorizontalAlignment="Left" Margin="-10,0,0,0" Name="searchBox1" Text="Search..." VerticalAlignment="Top" Width="336" TextChanged="searchBox1_TextChanged" />
                <Button Content="→" Height="72" HorizontalAlignment="Right" Margin="-15,0,0,0" Name="searchButton" VerticalAlignment="Top" Width="74" Click="button1_Click_1"  />                
            </StackPanel>
            <ListBox Height="533" Name="listBox" Width="452" ScrollViewer.VerticalScrollBarVisibility="Visible" DoubleTap="textBlock_DoubleTap" SelectionChanged="listBox_SelectionChanged" Padding="2,5">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Height="30" Text="" Margin="2,10" Name="textBlock1" DoubleTap="TextBlock_DoubleTap" Visibility="Visible"/>
                        </StackPanel>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
        </StackPanel>
    </Grid>

Вот XAML, куда добавляются элементы. Струнная часть работает.

try
{
    if (root2.getSOCSectionListByNbrResponse.ClassOffered.ClassNumber != null) 
        text = text + root2.getSOCSectionListByNbrResponse.ClassOffered.ClassNumber;
    if (root2.getSOCSectionListByNbrResponse.ClassOffered.SectionNumber != null) 
        text = text + "   " + root2.getSOCSectionListByNbrResponse.ClassOffered.SectionNumber;
    if (root2.getSOCSectionListByNbrResponse.ClassOffered.CourseDescr != null) 
        text = text + "   " + root2.getSOCSectionListByNbrResponse.ClassOffered.CourseDescr;
    if (root2.getSOCSectionListByNbrResponse.ClassOffered.SectionTypeDescr != null) 
        text = text + "   " + root2.getSOCSectionListByNbrResponse.ClassOffered.SectionTypeDescr;
    if (root2.getSOCSectionListByNbrResponse.ClassOffered.Meeting.Days != null) 
        text = text + "   " + root2.getSOCSectionListByNbrResponse.ClassOffered.Meeting.Days;
    if (root2.getSOCSectionListByNbrResponse.ClassOffered.Meeting.Times != null) 
        text = text + "   " + root2.getSOCSectionListByNbrResponse.ClassOffered.Meeting.Times;
    if (root2.getSOCSectionListByNbrResponse.ClassOffered.Instructor.InstructorName != null) 
        text = text + "   " + root2.getSOCSectionListByNbrResponse.ClassOffered.Instructor.InstructorName;
    if (root2.getSOCSectionListByNbrResponse.ClassOffered.EnrollmentStatus != null) 
        text = text + "   " + root2.getSOCSectionListByNbrResponse.ClassOffered.EnrollmentStatus;
}
catch (Exception e)
{

}

listBox.Items.Add(text);

person user3502946    schedule 12.04.2014    source источник
comment
Покажите какой-нибудь код, пожалуйста   -  person csharpwinphonexaml    schedule 13.04.2014
comment
Ожидаете ли вы увидеть каждый текст, добавленный в каждый элемент? или вы делаете вокруг этого?   -  person csharpwinphonexaml    schedule 13.04.2014
comment
Вокруг этого есть большое число, которое включает новый вызов API для каждой итерации. Таким образом, весь текст представляет собой один элемент и будет меняться каждый раз. Когда я нажимаю на невидимые ссылки, он переходит с правильной информацией.   -  person user3502946    schedule 14.04.2014
comment
Пожалуйста, попробуйте то, что я разместил в качестве ответа   -  person csharpwinphonexaml    schedule 14.04.2014


Ответы (1)


Я только что просмотрел код, который вы разместили, и нашел решение:

Замените это:

<DataTemplate>
    <StackPanel Orientation="Horizontal">
        <TextBlock Height="30" Text="" Margin="2,10" Name="textBlock1" DoubleTap="TextBlock_DoubleTap" Visibility="Visible"/>
    </StackPanel>
</DataTemplate>

с этим:

<DataTemplate>
    <TextBlock 
        Height="30" Text="{Binding}" Margin="2,10" 
        Name="textBlock1" DoubleTap="TextBlock_DoubleTap" 
        Visibility="Visible"/>
</DataTemplate>
person csharpwinphonexaml    schedule 14.04.2014