本文介绍了如何在C#中使用ExpandableObject装饰属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图按照:
PG.SelectedObject = new Order()
{
ShipAddress = "Luisenstr. 48",
ShipCountry = "Germany",
ShipName = "Toms Spezialitaten",
ShipPostalCode = "44087",
chronology = new OrderChronology()
{
OrderDate = new DateTime(1996, 7, 5),
ShippedDate = new DateTime(1996, 8, 16)
}
};
类似于我尝试做的行为的Xceed示例说 you必须使用ExpandableObject属性来装饰您的媒体资源。
并显示以下内容:
The Xceed example for behavior analogous to what I am trying to do says you must decorate your property with the ExpandableObject attribute.
and shows this:
public class Person
{
[Category("Information")]
[DisplayName("First Name")]
[Description("This property uses a TextBox as the default editor.")]
public string FirstName { get; set; }
[Category("Conections")]
[Description("This property is a complex property and has no default editor.")]
[ExpandableObject]
public Person Spouse { get; set; }
}
当我尝试对班级做同样的事情(见下文)时导致编译器错误;它不喜欢 [ExpandableObject]
,并暗示我可能缺少using指令或程序集引用
。是吗?
When I try to do the same with my class (see below) it causes a compiler error; it does not like [ExpandableObject]
and hints that I may be missing a using directive or assembly reference
. Am I?
public class Order
{
public string ShipAddress { get; set; }
public string ShipCountry { get; set; }
public String ShipName { get; set; }
public String ShipPostalCode { get; set; }
[ExpandableObject]
public OrderChronology chronology;
}
public class OrderChronology
{
public DateTime OrderDate { get; set; }
public DateTime ShippedDate { get; set; }
}
推荐答案
您应添加程序集 Xceed.Wpf.Toolkit.dll
,然后应添加以下命名空间:
You should add assembly Xceed.Wpf.Toolkit.dll
and after that you should add following namespace:
using Xceed.Wpf.Toolkit.PropertyGrid.Attributes;
这篇关于如何在C#中使用ExpandableObject装饰属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!