繁体   English   中英

绑定到列表<UserControl>

[英]Binding on a List<UserControl>

我遇到一些有约束力的问题...

Shapes是自定义UserControl的列表,例如,其中的UserControl可以是具有某些特定属性的Ellipse。 我的目标是循环显示此列表,并显示所有UserControl(它可以是一个Ellipse或Rectangle ...),我只想显示UserControl,就像我只是提示他的XAML内容一样。

这是我的网格,我只是不知道要在DataTemplate中放入什么,我尝试了一些不同的操作,但实际上没有任何效果,希望其中一些可以帮助我:)

<Grid>
    <s:ScatterView ItemsSource="{Binding Shapes}">
        <s:ScatterView.ItemContainerStyle>
            <Style TargetType="s:ScatterViewItem">
                <Setter Property="Background" Value="Transparent"></Setter>
            </Style>
            </s:ScatterView.ItemContainerStyle>
            <s:ScatterView.ItemTemplate>
            <DataTemplate>
                <class:Shape ShapeItem="{Binding}" />
            </DataTemplate>
        </s:ScatterView.ItemTemplate>
    </s:ScatterView>
</Grid>

如comment.if所述,如果ShapeItem是UserControl,请尝试将其与Content Property绑定。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM