C# 接口扩展后的同一命名空间中出现错误
早上好,伙计们,我有点小问题 有一个名为SettingsPage的类,它扩展了PageBase。PageBase依次扩展IPageBase和Page 在SettingsPage Xaml的图形页面中,我指定它的类型为PageBase,这会导致错误 错误表示PageBase不存在于同一上下文中,但名称空间相同 我把你放在班级比赛下面 PageBase.csC# 接口扩展后的同一命名空间中出现错误,c#,xaml,uwp-xaml,C#,Xaml,Uwp Xaml,早上好,伙计们,我有点小问题 有一个名为SettingsPage的类,它扩展了PageBase。PageBase依次扩展IPageBase和Page 在SettingsPage Xaml的图形页面中,我指定它的类型为PageBase,这会导致错误 错误表示PageBase不存在于同一上下文中,但名称空间相同 我把你放在班级比赛下面 PageBase.cs namespace EVS.Pages { public class PageBase : Page, IPagebase {
namespace EVS.Pages
{
public class PageBase : Page, IPagebase
{
string IPagebase.Title => "No Title";
}
public interface IPagebase
{
String Title { get; }
}
}
设置spage.xaml.cs
namespace EVS.Pages
{
public sealed partial class SettingsPage : PageBase
{
string Title => "Settings";
public SettingsPage()
{
this.InitializeComponent();
}
}
}
setingspage.xaml
<local:PageBase
x:Class="EVS.Pages.SettingsPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:EVS.Pages"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<TextBlock>Test</TextBlock>
</Grid>
</local:PageBase>
提前感谢您的进一步澄清这可能是因为项目的obj和bin文件夹中遗漏了一些临时文件
单击“生成”菜单中的“清理解决方案”,然后关闭Visual Studio并删除项目文件夹中的obj和bin文件夹。应用程序是否仍在编译?在这种情况下,设计师有时是非常不可靠的。不,它不是。你可以单击“构建”菜单中的“清理解决方案”,然后关闭visual studio并删除项目文件夹中的obj和bin文件夹吗?奇怪的是,我已经清理了项目,现在它似乎可以工作了,非常感谢。muchI将写一个答案:-。