仿真器提供不同的结果

时间:2013-03-29 21:32:32

标签: windows-phone-7 listview data-binding windows-phone-7-emulator windows-phone-8-emulator

我正在Windows Phone上开发一个应用程序,其中7.1版本设置为我的目标版本。我遇到的问题是我的页面上的一个列表视图拒绝显示。

我已经调试过以确保列表中的内容被解析。当我使用Windows 8模拟器时,应用程序运行正常。但是,在应用程序的其他页面中填充其他列表视图时使用的相同技术可以在此单页面中显示的所有模拟器上正常工作。

我甚至尝试设置绑定堆栈面板的颜色,看它是否会显示,但它没有任何内容。 我真的很困惑,我的代码非常完美。我想知道在使用Windows Phone模拟器之前是否有任何人出现这个问题?

private void countdownClient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
    {
        HtmlDocument doc = new HtmlDocument();            
        if (e.Error != null)
        {
            //MessageBox.Show(e.Error.InnerException.Message + "\n Ensure You Have A Working Internet Connection");                
            return;
        }
        doc.LoadHtml(e.Result);
        String noCountdown = "<div><span>Sorry no buses are expected within 30 minutes of this stop.  Please try again later or go to www.tfl.gov.uk</span></div>";

        if (e.Result.Contains(noCountdown))
        {
            //No Buses Expected;
            return;
        }
        else
        {
            HtmlNode stopCountdownNode;
            try
            {
                stopCountdownNode = doc.DocumentNode.SelectSingleNode("//*[contains(@id, 'stopBoard')]").SelectSingleNode("tbody");
            }
            catch (Exception)
            {
                MessageBox.Show("Error Responce From Server");
                return;
            }

            if (stopCountdownNode != null)
            {
                HtmlNodeCollection countdownNodeList = stopCountdownNode.SelectNodes("tr");
                CountDownListBox.ItemsSource = GetCountdownList(countdownNodeList);
            } 
        }
    }

    private ObservableCollection<BusCountdown> GetCountdownList(HtmlNodeCollection countdownNodeList)
    {
        ObservableCollection<BusCountdown> countdownList = new ObservableCollection<BusCountdown>();
        foreach (HtmlNode countDown in countdownNodeList)
        {
            String busName = HttpUtility.HtmlDecode(countDown.SelectSingleNode("*[contains(@class, 'resRoute')]").InnerHtml);
            String busDestination = HttpUtility.HtmlDecode(countDown.SelectSingleNode("*[contains(@class, 'resDir')]").InnerHtml);
            String countDownTime = HttpUtility.HtmlDecode(countDown.SelectSingleNode("*[contains(@class, 'resDue')]").InnerHtml);
            countdownList.Add(new BusCountdown(busName, busDestination, countDownTime));       
        }                                                    
        return countdownList;
    }

    public string GetRandomSlash()
    {
        Random r = new Random();
        String slash = "";
        int rand = r.Next(1, 20);
        for (int i = 0; i < rand; i++)
        {
            slash += "/";
        }
        return slash;
    }

2 个答案:

答案 0 :(得分:1)

尝试设置用于绑定到public的类访问说明符并尝试一下。如果有效,请告诉我。

例如:

public class Bindingclass
{
public string Name{get;set;}
}

答案 1 :(得分:0)

  1. 尝试使用 Expression Blend ,并删除以前的解决方案文件和构建新解决方案
  2. 还要为所有网页正确设置构建操作属性。
  3. SDK更新为7.8 版本。您将获得多种仿真器选择 - 仿真器7.1(256 MB),仿真器7.1(512 MB),仿真器7.8(256 MB),仿真器7.8(512 MB)。在所有这些版本上测试它并检查每个仿真器类型的输出。
  4. 我希望其中至少有一项可以帮助你让事情变得有效。请告诉我们。