C# StackPanel的奇怪问题

C# StackPanel的奇怪问题,c#,windows-phone-7,xaml,C#,Windows Phone 7,Xaml,我用这个StackPanel在我的应用程序中显示图像时遇到了一个非常奇怪的问题。最近,它似乎开发了一个无形的“高度限制”,即使它被放置在ScrollViewer中 <Grid x:Name="AttachmentList" Grid.Row="1" Margin="12,0,12,0"> <Button Content="Add Attachment" Height="88" Name="btnAdd" HorizontalAlignment="Left

我用这个StackPanel在我的应用程序中显示图像时遇到了一个非常奇怪的问题。最近,它似乎开发了一个无形的“高度限制”,即使它被放置在ScrollViewer中

    <Grid x:Name="AttachmentList" Grid.Row="1" Margin="12,0,12,0">
        <Button Content="Add Attachment" Height="88" Name="btnAdd" HorizontalAlignment="Left" VerticalAlignment="Top" Width="246" Click="btnAdd_Click" Margin="-12,-28,0,0" />
        <Button Content="Take Photo" Height="88" HorizontalAlignment="Right" Margin="0,-28,-12,0" Name="btnTakePic" VerticalAlignment="Top" Width="246" Click="btnTakePic_Click"/>
        <Button Content="Remove Selected" Height="88" Margin="-12,48,0,0" Name="btnDelete" HorizontalAlignment="Left" VerticalAlignment="Top" Width="246" Click="btnDelete_Click" />
        <Button Content="Done" Height="88" HorizontalAlignment="Right" Margin="0,48,-12,0" Name="btnDone" VerticalAlignment="Top" Width="246" Click="btnDone_Click" />
        <ScrollViewer  BorderThickness="0" Margin="0,142,0,0">
            <StackPanel Name="DisplayPanel" Orientation="Vertical" HorizontalAlignment="Left" VerticalAlignment="Top" />
        </ScrollViewer> 
    </Grid>
这个问题过去没有发生过。在我的应用程序的所有以前的版本中,所有的东西都能完美地工作,所以我不知道为什么现在会发生这种情况。我已经好几个星期没有碰过这个页面的代码了。然而,最近我确实将我的整个项目从WindowsPhoneOS7.0升级到了7.1。这可能是原因吗?如果是,我能做些什么来修复它


编辑:通过将每个图像放在其自己的堆栈面板中,并将这些面板添加到最终的显示面板中,而不是单独添加图像,最终解决了问题。我猜这毕竟是堆栈面板的“限制”问题…它们不能包含那么多图像

问题可能是e.ChoosePhoto,其中某个图像不能从web服务正确渲染?为了确保这一点,将一些不同高度的静态图像添加到项目中,并将它们从代码隐藏添加到静态面板中。测试它们是如何呈现的。@nkchandra我只测试了手机内存中存储的图像,所以这不应该是web服务的问题。根据我添加到面板的图像的大小,“消失”将在不同的时间发生。例如,当我使用均匀中等高度的图像时,第六个图像消失。然而,如果我只添加高的图像,第三个或第四个图像可能会消失。
private void imageTask_Completed(object sender, PhotoResult e)
{
  if (e.TaskResult == TaskResult.OK)
  {
    string[] splicedPath = e.OriginalFileName.Split('\\');
    string imageName = splicedPath[splicedPath.Length - 1];

    imageDict.Add(imageName, e.ChosenPhoto);

    BitmapImage bmp = new BitmapImage();
    bmp.SetSource(e.ChosenPhoto);

    Image pic = new Image();
    pic.Source = bmp;
    pic.Tag = imageName;
    pic.Margin = new Thickness(0, 0, 0, 15);
    pic.MouseLeftButtonUp += new MouseButtonEventHandler(pic_MouseLeftButtonUp);
    DisplayPanel.Children.Add(pic);
  }
}