首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >抽象类面板上的Silverlight ContentProperty

抽象类面板上的Silverlight ContentProperty
EN

Stack Overflow用户
提问于 2010-08-23 21:26:41
回答 1查看 434关注 0票数 0

下面是我的类MyContainer的层次结构。注意,PanelChildrenMyContainer。我还可以使用来自PanelPanel吗?

[ContentProperty("Children", true)]的含义是什么?摘要说明:

指定当XAML处理器解析类时,可以将该类的哪个属性解释为内容属性。

但我不明白他的意思?

代码语言:javascript
复制
[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;}
}
EN

回答 1

Stack Overflow用户

发布于 2010-08-23 21:42:39

ContentProperty属性意味着以下两个元素是等价的-- Canvas的子属性是画布的默认内容。

代码语言:javascript
复制
<Canvas>
    <TextBlock Text="Hello"/>
    <Button Content="World"/>
</Canvas>

<Canvas>
    <Canvas.Children>
        <TextBlock Text="Hello"/>
        <Button Content="World"/>
    </Canvas.Children>
</Canvas>
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3551842

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档