0

ItemsControl.Items是否可以通过绑定以某种方式将集合传递给控件中的每个单独项目?

我想要做的看起来像这样(特别是 WorkspaceCubes 绑定):(它目前不起作用,因为您无法绑定到 anItemsControl或其Items

<ItemsControl x:Name="workspace" ItemsSource="{Binding Path=CubeViewModels}">
    <ItemsControl.ItemsPanel>
        <ItemsPanelTemplate>
            <Canvas Background="SkyBlue" Margin="0"></Canvas>
        </ItemsPanelTemplate>
    </ItemsControl.ItemsPanel>
    <ItemsControl.ItemTemplate>
        <DataTemplate>
            <Canvas>
                <Sift:CubeView WorkspaceCubes="{Binding ElementName=workspace, Path=Items}"  DataContext="{Binding}"></Sift:CubeView>
            </Canvas>
        </DataTemplate>
    </ItemsControl.ItemTemplate>
</ItemsControl>
4

1 回答 1

0

不确定您的目的,但您可以尝试:

<ItemsControl x:Name="workspace" ItemsSource="{Binding Path=CubeViewModels}" DataContext="{Binding Path=CubeViewModels}"> 
    <ItemsControl.ItemsPanel> 
        <ItemsPanelTemplate> 
            <Canvas Background="SkyBlue" Margin="0"></Canvas> 
        </ItemsPanelTemplate> 
    </ItemsControl.ItemsPanel> 
    <ItemsControl.ItemTemplate> 
        <DataTemplate> 
            <Canvas> 
                <Sift:CubeView WorkspaceCubes="{Binding}"></Sift:CubeView> 
            </Canvas> 
        </DataTemplate> 
    </ItemsControl.ItemTemplate> 
</ItemsControl> 
于 2012-04-27T03:29:17.193 回答