[英]CS0234: The type or namespace name '<namespace2>' does not exist in the namespace '<namespace1>.' (are you missing an assembly reference?)
[英]The type or namespace name does not exist in the namespace <Page>.g.cs
我正在制作一個需要使用自定義BasePage的應用程序,該應用程序的所有其他頁面都將從該自定義BasePage繼承。 我創建了一個新的TestProject並完成了以下所有工作:Perfactly可以正常工作 ,但是當我在MyProject中執行相同的操作時,會發生錯誤
類型或名稱空間名稱在名稱空間TestPage.g.cs中不存在
這是BaseScreenPage的代碼
namespace MyProject
{
public class BaseScreenPage : PhoneApplicationPage
{
private static bool isToShowAgain = true ;
public static bool isToNavigateToContent;
public BaseScreenPage()
{
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
if (isToNavigateToContent) {
isToNavigateToContent = false;
NavigationService.Navigate(new Uri("/Screens/ContentScreen.xaml", UriKind.Relative));
}
}
}
}
我正在制作從BaseScreenPage
繼承的頁面
<hyper:BaseScreenPage
x:Class="MyProject.TestPage"
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"
xmlns:hyper="clr-namespace:MyProject"
shell:SystemTray.IsVisible="True">
<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!--TitlePanel contains the name of the application and page title-->
<StackPanel Grid.Row="0" Margin="12,17,0,28">
<TextBlock Text="MY APPLICATION" Style="{StaticResource PhoneTextNormalStyle}"/>
<TextBlock Text="page name" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
</StackPanel>
<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
</Grid>
</Grid>
</hyper:BaseScreenPage>
我也在TestPage的代碼中這樣做
namespace MyProject
{
public partial class TestPage : BaseScreenPage
{
public TestPage()
{
InitializeComponent();
}
}
}
我已經嘗試過所有問題的解決方案
請提出一些解決方案
我不確定這是否是問題的原因,但是您的XAML對我來說似乎是錯誤的。 您在hyper
XML名稱空間中聲明了BasePage
節點,但尚未在任何地方聲明該名稱空間。 您缺少聲明:
<hyper:BaseScreenPage
x:Class="MyProject.TestPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:hyper="declareYourNamespaceHere"
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"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.