编辑:对不起,这是wpf
我用来实现相同目的的技巧是创建一个触发器来显示默认为折叠的辅助网格.
试试这个:
<ListBox ItemsSource="{Binding}">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Grid Grid.Row="0" Height="20" >
<TextBlock Text="Not Selected"></TextBlock>
</Grid>
<Grid x:Name="selectedOnlyGrid" Grid.Row="1" Visibility="Collapsed">
<TextBlock Text="Selected"></TextBlock>
</Grid>
</Grid>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem}, AncestorLevel=1}, Path=IsSelected}" Value="True">
<Setter Property="Visibility" Value="Visible" TargetName="selectedOnlyGrid" />
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
Run Code Online (Sandbox Code Playgroud)