列表框内的wp7文本块未显示

时间:2013-06-24 13:33:15

标签: c# windows windows-phone-7 data-binding listbox

这是让我疯狂的代码。它在Windows 8(Snap View)上运行良好,但是当我尝试在我的Windows Phone 7应用程序中运行相同的XAML时,它不起作用。

发生什么 应用程序运行正常,但问题是屏幕是空白的。我试图在itemtemplate中添加一些背景,它确实显示了这意味着数据绑定可能正在工作。但是5个文本块的内容没有显示出来。

<ListBox x:Name="result_s" Margin="0,296,0,0" HorizontalAlignment="Center" VerticalAlignment="Top">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <StackPanel Margin="8,8,48,8" Orientation="Horizontal" Height="80">
                        <TextBlock HorizontalAlignment="Left" VerticalAlignment="Bottom" FontSize="24" Width="auto" TextWrapping="Wrap" Margin="0,0,0,0" Text="{Binding coeff}"/>
                        <TextBlock HorizontalAlignment="Left" VerticalAlignment="Bottom" FontSize="24" Width="auto" TextWrapping="Wrap" Margin="4,0,0,0" Text="{Binding x}"/>
                        <TextBlock HorizontalAlignment="Left" VerticalAlignment="Bottom" FontSize="24" Width="auto" TextWrapping="Wrap" Margin="0,0,0,16" Text="{Binding xPow}"/>
                        <TextBlock HorizontalAlignment="Left" VerticalAlignment="Bottom" FontSize="24" Width="auto" TextWrapping="Wrap" Margin="4,0,0,0" Text="{Binding y}"/>
                        <TextBlock HorizontalAlignment="Left" VerticalAlignment="Bottom" FontSize="24" Width="auto" TextWrapping="Wrap" Margin="0,0,0,16" Text="{Binding yPow}"/>
                    </StackPanel>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>

以下是

背后的代码
void func()
{
   ObservableCollection<Equation> answer = new ObservableCollection<Equation>();
   // SOME CODE GOES IN HERE, THE CODE POPULATES answer
   result_s.ItemsSource = null;
   result_s.ItemsSource = answer;
}

请你能看到任何不起作用的原因。

0 个答案:

没有答案