【问题标题】:My application crashed when snapped with items in listviews与列表视图中的项目对齐时,我的应用程序崩溃了
【发布时间】:2013-05-02 08:18:52
【问题描述】:

所以,我目前正在开发一个使用 C#/XAML 开发 Windows 8 应用商店应用程序的项目,我遇到了一个问题。

当用户导航到页面时,会显示带有一些控件的 ListView。 然后,当用户决定捕捉页面时,我的应用程序崩溃并显示:

在我的 IntelliTrace 中,这会显示出来,然后我按下异常。

它将我导航到此代码。

     /// <summary>
    /// Implement this partial method to configure the service endpoint.
    /// </summary>
    /// <param name="serviceEndpoint">The endpoint to configure</param>
    /// <param name="clientCredentials">The client credentials</param>

    static partial void ConfigureEndpoint(System.ServiceModel.Description.ServiceEndpoint serviceEndpoint, System.ServiceModel.Description.ClientCredentials clientCredentials);

    public EmployeeAssisterClient() : 
            base(EmployeeAssisterClient.GetDefaultBinding(), EmployeeAssisterClient.GetDefaultEndpointAddress()) {
        this.Endpoint.Name = EndpointConfiguration.TimeLoggerEndPoint.ToString();
        ConfigureEndpoint(this.Endpoint, this.ClientCredentials);
    }

我将控件添加到列表视图中,如下所示:

            _timeReports = _timeReportDatabase.GetAll();

            foreach (var timeReport in _timeReports)
            {
                _invoicedControls.Add(new InvoicedControl(timeReport)
                    {
                        Customer = timeReport.CustomerName,
                        Date = timeReport.Date,
                        WorkedTime = timeReport.WorkedTime.ToString(),
                        InvoicedTime = timeReport.InvoicedTime.ToString()
                    });
            }

            TimeReportsListViewFillView.ItemsSource = _invoicedControls;
            TimeReportsListViewFullView.ItemsSource = _invoicedControls;
            TimeReportsListViewPortraitView.ItemsSource = _invoicedControls;
            TimeReportsListViewSnappedView.ItemsSource = _invoicedControls;

编辑=============================================== =================================

这是抛出的错误

我通过在 Cmd 中键入“C:\Program Files\Microsoft Visual Studio 11.0\Common7\IDE\VsDiag_regwcf.exe -u”关闭了 WCF 调试,它解决了 2/3 的问题

这是我的 IntelliTrace 中的最后一个错误:

这个错误是什么意思? any1 知道如何解决这个问题吗?

【问题讨论】:

  • 请查看 Visual Studio 2012 中的“Locals”窗格,您会注意到一个名为 $exception 的值。它有什么价值。看到这个screen shot
  • 这是我的本地人在应用程序崩溃时的样子:oi42.tinypic.com/35nacko.jpg
  • 这是ArgumentException投掷。
  • 我应该在哪里捕获 ArgumentException?在 NavigateTo 上?

标签: c# windows-8 microsoft-metro windows-store-apps windows-applications


【解决方案1】:

根据您显示的内容,您很可能使用了生成的页面(来自模板),然后删除了其中的一些 Xaml,这很好。

您可能没有做的事情是删除了对您从 VisualStateManager 的情节提要中删除的那些控件的引用,特别是针对 Snapped 状态。

转到您的页面并检查(通常在底部)Xaml 中的“Snapped”VisualState,然后检查是否有任何情节提要具有您不再拥有的控件的 TargetName。

【讨论】:

  • 感谢您的回复。我使用了基本页面,它为我生成了一个 backButton 和一个 pageTitle。但是当我从页面中删除它们时,我确实也将它们从我的 StoryBoard 中删除了。 (我的 StoryBoard 只包含 4 个 TargetName:“FullView、SnappedView、FillView 和 PortraitView”(我的 4 个 VisualStates 中的每一个都有这些 StoryBoard)。
猜你喜欢
  • 2020-03-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-11-27
相关资源
最近更新 更多