簡體   English   中英

Windows Phone 8-找不到XAML錯誤

[英]windows phone 8 - xaml not found error

我的申請書有兩頁。 這兩個頁面都位於“查看文件夾”中( SplashScreen.xamlGetPhoneNumber.xaml )。 我指定<DefaultTask Name ="_default" NavigationPage="View/SplashScreen.xaml"/>

運行此代碼后,出現錯誤=> xaml未找到。 我在應用程序的根目錄中創建了2個xaml文件,並重復此方案,但問題不存在

SplashScreen.xaml.cs

public partial class SplashScreen : PhoneApplicationPage
{
    System.Windows.Threading.DispatcherTimer _splashTimer;

    public SplashScreen()
    {
        InitializeComponent();
        _splashTimer = new System.Windows.Threading.DispatcherTimer();
        Loaded += new RoutedEventHandler(Page_Loaded);
    }

    void Page_Loaded(object sender, RoutedEventArgs e)
    {
        if (_splashTimer != null)
        {
            _splashTimer.Interval = new TimeSpan(0, 0, 5);
            _splashTimer.Tick += new EventHandler(_splashTimer_Tick);
            _splashTimer.Start();
        }
    }

    void _splashTimer_Tick(object sender, EventArgs e)
    {
        _splashTimer.Stop();
        _splashTimer.Tick -= new EventHandler(_splashTimer_Tick);
        _splashTimer = null;
        NavigationService.Navigate(new Uri("/GetPhoneNumber.xaml", UriKind.Relative));

    }

}

SplashScreen.xaml

<phone:PhoneApplicationPage
x:Class="Ghavamin.View.SplashScreen"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
mc:Ignorable="d"
shell:SystemTray.IsVisible="True">

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot"  Background="{StaticResource GrayBrush}">
        <Image Height="169" Margin="41,255,57,344" Width="382" HorizontalAlignment="Center" VerticalAlignment="Center" Source="/Image/splash.jpg"/>
    </Grid>

</phone:PhoneApplicationPage>

我已經創建了與您相同的文件夾和文件結構。 您的文件名有問題。 我剛剛將“ Splashscreen.xaml”重命名為“ Abc.xaml”,還重命名了所有相關類。 那對我來說很好。 Windows Phone OS可能會保留“啟動畫面”字樣。 目前,這是您的問題的解決方案。

您需要在xaml中指定確切的路徑。 它被指定為Ghavamin.View.SplashScreen ,這意味着您的SplashSceen.xaml存在於“ View文件夾”中。 因此,如下所述更改xaml或在調用Navigate()方法時包括確切路徑。

 <phone:PhoneApplicationPage
x:Class="Ghavamin.SplashScreen"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
mc:Ignorable="d"
shell:SystemTray.IsVisible="True">

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot"  Background="{StaticResource GrayBrush}">
        <Image Height="169" Margin="41,255,57,344" Width="382" HorizontalAlignment="Center" VerticalAlignment="Center" Source="/Image/splash.jpg"/>
    </Grid>

</phone:PhoneApplicationPage>

暫無
暫無

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

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