私はこのようなC#MAINWINDOW.xaml.csに文字列のコレクションを持っています
public class NameList : ObservableCollection<Shortcuts>
{
public NameList() : base()
{
Add(new Shortcuts("ctrl", "b","s"));
Add(new Shortcuts("ctrl", "b","m"));
Add(new Shortcuts("ctrl", "b","p"));
Add(new Shortcuts("ctrl", "b","1"));
}
}
public class Shortcuts
{
private string firstkey;
private string secondkey;
private string lastkey;
public Shortcuts(string first, string second, string last)
{
this.firstkey = first;
this.secondkey = second;
this.lastkey= last;
}
public string Firstkey
{
get { return firstkey; }
set { firstkey = value; }
}
public string Secondkey
{
get { return secondkey; }
set { secondkey = value; }
}
public string Lastkey
{
get { return lastkey; }
set { lastkey = value; }
}
}
}
次に、MainWindow.xaml自体にコンボボックスがあり、これらのアイテムをコンボボックスにバインドしたいので、これを実行しました
<Window x:Class="Testing_learning.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:c="clr-namespace:Testing_learning"
Title="Outlook Context Settings" Height="350" Width="525">
<Window.Resources>
<c:ListName Key ="NameListData"/>
</Window.Resources>
ところで、プロジェクト名はTesting_learningであるため、これがあります
xmlns:c="clr-namespace:Testing_learning"
しかし、問題は、このコード行を追加すると
<Window.Resources>
<c:ListName Key ="NameListData"/>
</Window.Resources>
c:ListNameでエラーが発生します。タイプListNameが見つかりませんでした。これはなぜですか。何かご意見は?
スクリーンショット1
スクリーンショット2