How can I change listbox item's visibility property in wp7?

后端 未结 1 1226
孤街浪徒
孤街浪徒 2021-01-27 16:37

For example: there is a listbox:


  

        
相关标签:
1条回答
  • 2021-01-27 17:22

    The ListBoxgenerates a container of type ListBoxItem for each item. You can access it as follows:

    ListBoxItem lbi = lb.ItemContainerGenerator.ContainerFromIndex(0) as ListBoxItem
    lbi.Visibility = Visibility.Collapsed;
    

    If you want access to the TextBlock you will need to navigate the visual tree of the ListBoxItem. For example, using Linq to VisualTree:

    TextBlock txt = lbi.Descendants<TextBlock>().Single() as TextBlock;
    
    0 讨论(0)
提交回复
热议问题