繁体   English   中英

将包装面板添加到列表视图项

[英]Adding a Wrap Panel to a Listview Item

我已经在整个互联网上进行了搜索,但没有找到解决我问题的答案。

我希望能够有一个包含两列的列表视图,一列带有文本,一列带有可将图像拖入的包装面板。

我目前正在将listview绑定到数据集,因此WPF列会选择所述数据集的列。

<GridViewColumn Width="100" Header="Name" DisplayMemberBinding="{Binding Path=Name}"/>
<GridViewColumn Width="110" Header="Items" >
    <GridViewColumn.CellTemplate>
        <DataTemplate>
             <WrapPanel DataContext="{Binding Path=Items}" />
        </DataTemplate>
    </GridViewColumn.CellTemplate>
</GridViewColumn>

我试图使用此代码及其许多变体,但我只是找不到绑定它的方法。

如果设置DataContext ,则WrapPanels不会自动填充自身,您需要一个ItemsControl以及一个ItemsPanel ,它是WrapPanel (绑定ItemsSource )。

<ItemsControl ItemsSource="{Binding Items}">
    <ItemsControl.ItemsPanel>
        <ItemsPanelTemplate>
            <WrapPanel />
        </ItemsPanelTemplate>
    </ItemsControl.ItemsPanel>
</ItemsControl>

暂无
暂无

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

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