开发者

Access nested items in CollectionViewGroup

开发者 https://www.devze.com 2023-02-04 17:37 出处:网络
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 im

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

精彩评论

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