C# ';无效';属性类型还是设计器错误?
我有一个叫做C# ';无效';属性类型还是设计器错误?,c#,wpf,C#,Wpf,我有一个叫做 ISquare 有一个具有公共属性的usercontrol MatrixGrid public List<List<ISquare>> Squares { get { return (List<List<ISquare>>)GetValue(SquaresProperty); } set { SetValue(SquaresProperty);} } 设计器的Gui部分显示 Invalid Markup, ch
ISquare
有一个具有公共属性的usercontrol MatrixGrid
public List<List<ISquare>> Squares
{
get { return (List<List<ISquare>>)GetValue(SquaresProperty); }
set { SetValue(SquaresProperty);}
}
设计器的Gui部分显示
Invalid Markup, check the error list for more information
运行程序时,所有绑定都能正常工作,一切正常
这是设计器中的一个bug,还是在某个地方写下了一条规则
我正在为Windows桌面运行Visual Studio Express 2012
我可以用下面的代码复制它
TestControl.xaml.cs
public partial class TestControl : UserControl
{
public TestControl()
{
InitializeComponent();
}
public static DependencyProperty
TestProperty = DependencyProperty.Register("MyTest", typeof(List<List<Test>>), typeof(TestControl));
public List<List<Test>> MyTest { get { return (List<List<Test>>)GetValue(TestProperty); } set { SetValue(TestProperty, value); } }
}
public interface Test {}
public部分类TestControl:UserControl
{
公共测试控制()
{
初始化组件();
}
公共静态从属属性
TestProperty=dependencProperty.Register(“MyTest”、typeof(List)、typeof(TestControl));
公共列表MyTest{get{return(List)GetValue(TestProperty);}set{SetValue(TestProperty,value);}
}
公共接口测试{}
TestWindow.xaml
<Window x:Class="simthing.TestWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:simthing"
Title="TestWindow" Height="300" Width="300">
<Grid>
<local:TestControl MyTest="{Binding Tests}"/>
</Grid>
</Window>
重新构建解决方案后,错误仍然存在?它确实存在,关闭和重新打开解决方案也是如此,但正如我所说的,错误不会影响构建,只是设计人员。这与我所做的工作并不密切相关,这需要嵌套对象列表提供的二维性。假设它们是IEnumerables或ObservableCollections如果在测试控件属性getter和Setter中丢失,xaml designer使用getter和Setter通过intellisence显示属性并提示一些设计时错误,但是在运行时从依赖项对象使用getvalue和setvalue方法。
<Window x:Class="simthing.TestWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:simthing"
Title="TestWindow" Height="300" Width="300">
<Grid>
<local:TestControl MyTest="{Binding Tests}"/>
</Grid>
</Window>