在我的WPF程序中,我有一个ListBox
控件:
<ListBox x:Name="mailsListBox" SelectionChanged="mailsListBox_SelectionChanged" >
<ListBoxItem Content="..." Background="#FFF3F3F3" Margin="0,0,0,1" />
<ListBoxItem Content="...." Margin="0,0,0,1" Visibility="Hidden"/>
</ListBox>
如何访问Visibility
的{{1}}属性?我的代码不起作用:
ListBoxItems
答案 0 :(得分:3)
像这样:
==
或者您可以使用ItemContainerGenerator.ContainerFromItem
方法:
(mailsListBox.Items[1] as ListBoxItem).Visibility = Visibility.Visible;