プラハ:
こんにちは私は、UI要素のリストでitemControlを持つWPF(XAML)に少し新しいです。バインディングは、コレクションのプロパティで行われているところ。今、私の要件は、リストからのみ第一の要素を表示するために最初にされ、コレクションからのアイテムの残りを表示することのリストをクリックの終わり時に+ショーMoreボタンオプションを持ちます。..
<ItemsControl x:Name="ContentRoot" ItemsSource="{Binding MyCollections}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<grid>
<TextBox Text="{Binding }" />
<TextBox Text="{Binding }" />
</grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
Corentinペイン:
あなたは、両方のA持つことができますContentControl
(コレクションの最初の項目を表示する)とItemsControl
する場合にのみ(コレクション全体を表示)表示ToggleButton
例えばチェックされます。
<StackPanel>
<StackPanel.Resources>
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
<DataTemplate DataType="{x:Type local:MyViewModel}">
<Grid>
<TextBox Text="{Binding}" />
</Grid>
</DataTemplate>
</StackPanel.Resources>
<ContentControl Content="{Binding MyCollection[0]}"/>
<ToggleButton x:Name="toggle" Content="Show more"/>
<ItemsControl ItemsSource="{Binding MyCollection}" Visibility="{Binding ElementName=toggle, Path=IsChecked, Converter={StaticResource BooleanToVisibilityConverter}}"/>
</StackPanel>
次に、あなたの正確なニーズに合わせて、これを適応させることができます。