gpt4 book ai didi

wpf - 类型 src :Videogames was not found. 验证您是否缺少程序集引用

转载 作者:行者123 更新时间:2023-11-30 23:50:25 26 4
gpt4 key购买 nike

我正在尝试绑定(bind) Videogame 的集合我的 ListBox 的对象,尽管遵循 MSDN,但我收到此错误例子。

enter image description here

<Grid>
<Grid.Resources>
//Error is fired here.
<src:Videogames x:Key="videogames" />

这是我的电子游戏课:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;

namespace UpcomingGames
{
public class Videogame
{
public string Name { get; set; }
public string ReleaseDate { get; set; }
public string Synopsis { get; set; }
public string Developer { get; set; }
}

public class Videogames : ObservableCollection<Videogame>
{
public Videogames()
{
Add(new Videogame {
Name = "Fire Emblem",
ReleaseDate = "20/4/2011",
Developer = "Rockstar Games",
Synopsis = @"Lorem ipsum dolor...",
});
Add(new Videogame {
Name = "Fire Emblem",
ReleaseDate = "20/4/2011",
Developer = "Rockstar Games",
Synopsis = @"Lorem ipsum dolor...",
});
Add(new Videogame{
Name = "Fire Emblem",
ReleaseDate = "20/4/2011",
Developer = "Rockstar Games",
Synopsis = @"Lorem ipsum dolor...",
});
}
}
}

我可能做错了什么,我能做些什么来解决这个问题?

我没有手动添加任何命名空间,因为 MSDN 文章没有告诉我。这是我需要做的吗?无论如何,这是 XAML 的当前状态。
<Window x:Class="UpcomingGames.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="286" Width="199">

最佳答案

这会为你做 -

<Window x:Class="UpcomingGames.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:src="clr-namespace:UpcomingGames"
Title="MainWindow" Height="286" Width="199">

对于您在上述帖子中报告的错误,只需从您的命名空间声明中删除程序集属性即可。

关于wpf - 类型 src :Videogames was not found. 验证您是否缺少程序集引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5849797/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com