我一直在摸不着头脑,我确信这是显而易见的但是我看不到它。
我制作了一个新的应用程序“WpfApplication3”
我添加了一个“Person.cs”类:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WpfApplication3
{
public class Person
{
public string Name { get { return "Jonas"; } }
}
}
然后我试试这个:
<Window x:Class="WpfApplication3.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WpfApplication3"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Grid.Resources>
<local:Person x:Key="somePerson"/>
</Grid.Resources>
<!--<TextBlock Text="{Binding {StaticResource somePerson.Name}}"/>-->
</Grid>
</Window>
我得到错误“名称”Person“在命名空间中不存在”clr-namespace:WpfApplication“。
我做错了什么?
使用VS Express 2012 for Windows桌面(试用版)。
答案 0 :(得分:0)
这看起来很奇怪,但我测试过,肯定不会找到Person。
然后我向人员添加了公共ctor
public class Person
{
public Person() { }
}
它会编译
现在我可以删除ctor,它将(仍然)编译
尝试(多次)清理并重建
我知道没有意义,但它发生在我身上