开发者

Access nested items in CollectionViewGroup

So i am trying to access some nested items in a CollectionView then bind them to a ListBox. Is there a simple way to do this? At the moment my ListBox is binding to "ContactListName" which is the immediate item but I would like to bind to "LabelName" which is开发者_开发技巧 a nested item of ContactList. Thanks - Ben


try setting DisplayMemberPath for ListBox

tagsList.ItemsSource = contactsList.SelectedItems;
tagsList.DisplayMemberPath = "LabelName";

if you are using ItemTemplate You need to set Binding

<DataTemplate x:Key="TagsTemplate">
        <WrapPanel>
            <TextBlock Text="{Binding LabelName, Mode=Default}" TextWrapping="Wrap" FontSize="{Binding ItemCount, Converter={StaticResource CountToFontSizeConverter}, Mode=Default}" Foreground="#FF0D0AF7"/>
        </WrapPanel>
    </DataTemplate>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜