下面是我的类MyContainer的层次结构。注意,Panel有Children和MyContainer。我还可以使用来自Panel的Panel吗?
[ContentProperty("Children", true)]的含义是什么?摘要说明:
指定当XAML处理器解析类时,可以将该类的哪个属性解释为内容属性。
但我不明白他的意思?
[ContentProperty("Children", true)]
public abstract class Panel : FrameworkElement
{
//
// Summary:
// Gets the collection of child elements of the panel.
//
// Returns:
// The collection of child objects. The default is an empty collection.
public UIElementCollection Children { get; }
}
public class Canvas : Panel
{....}
public class MyContainer : Canvas
{
public MyContainer();
public ObservableCollection<MyObject> Children {get;}
}发布于 2010-08-23 21:42:39
ContentProperty属性意味着以下两个元素是等价的-- Canvas的子属性是画布的默认内容。
<Canvas>
<TextBlock Text="Hello"/>
<Button Content="World"/>
</Canvas>
<Canvas>
<Canvas.Children>
<TextBlock Text="Hello"/>
<Button Content="World"/>
</Canvas.Children>
</Canvas>https://stackoverflow.com/questions/3551842
复制相似问题