簡體   English   中英

未將對象引用設置為Windows 8應用程序中的對象實例

[英]Object reference not set to an instance of an object in Windows 8 app

因此,在瀏覽了無數試圖找出其真正含義的資源之后,我發現絕對沒有任何用處。 讓我們澄清一下,我知道錯誤的含義。 但我不知道是什么原因造成的。 我的代碼如下:

private void Button_Click_1(object sender, RoutedEventArgs e)
{
    ListView selector = this.itemListView;
    FeedItem item = selector.SelectedItem as FeedItem;
    if (item != null && this.Frame != null)
    {
        this.Frame.Navigate(typeof(WebViewPage), item.Title); //This line is the problem
    }
}   

我試圖做的是基於itemListView的選擇導航到完整的Webview頁面。 我通過使用AppBar按鈕執行此操作。 當我逐行瀏覽此代碼時,一切都會按預期運行,直到嘗試導航為止。 在導航之前,我的所有對象都不為空(根據智能感知和輸入if語句的事實),並且在我逐步導航之后,它仍然保持這種狀態。 該程序不會失敗,它只會在Intellitrace框中顯示為異常,並且導航永遠不會發生,從而使用戶盡可能多地單擊appbar按鈕,但無濟於事。

Webview頁面代碼(根據IntelliTrace,我實際上從未在此頁面中找到任何代碼)。

protected override void LoadState(Object navigationParameter, Dictionary<String,Object> pageState)
{
    FeedItem item = FeedUtilities.GetItemByTitle((string)navigationParameter);
    pageTitle.DataContext = item;

    itemContentWebView.Navigate(item.Link);
}

這已經讓我沮喪了幾天,因此我們將不勝感激。

嘗試這個:

var rootFrame = new Frame();
rootFrame.Navigate(typeof(SearchResultsPage1));

Window.Current.Content = rootFrame;
Window.Current.Activate(); 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM