簡體   English   中英

命名空間中不存在XAML類

[英]XAML class does not exist in namespace

我得到一個錯誤,說新聞類在命名空間中不存在。

嘗試了在線提供的許多解決方案,例如重建等,但似乎沒有任何效果。 任何幫助將不勝感激。

這頁紙

<Page
    x:Class="KS2Buddy.Home"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:KS2Buddy"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    xmlns:data="using:KS2Buddy">
    <Page.Resources>
        <DataTemplate x:DataType="data:News"
                      x:Key="NewsItemTemplate">
        </DataTemplate>
    </Page.Resources>

</Page>

班級

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace KS2Buddy
{
    class News
    {
        public string Title { get; set; }
        public string Image { get; set; }
        public string Text { get; set; }
    }
}

如果您使用的是WPF,請嘗試替換

xmlns:data="using:KS2Buddy"

通過

xmlns:data="clr-namespace:KS2Buddy"

這個答案不針對UWP。

暫無
暫無

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

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