我有一个非常特别的请求;-)自定义ItemsControl与可选寻呼
我想开发一个ItemsControl与“上一个”控制和“下一个”控制。像这样结合到任意的视图模型:
<controls:PagedItemsControl ItemsSource="{Binding Items}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid Columns="5" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate DataType="system:String">
<Border Background="Gray" Margin="5">
<TextBlock Text="{Binding}" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center" />
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
<controls:PagedItemsControl.PreviousControl>
<Button Content="Previous" Command="{Binding PreviousCommand}" />
</controls:PagedItemsControl.PreviousControl>
<controls:PagedItemsControl.NextControl>
<Button Content="Next" Command="{Binding NextCommand}" />
</controls:PagedItemsControl.NextControl>
</controls:PagedItemsControl>
在这个例子中我经过视图模型的命令来控制2个按钮。如果有人能告诉我如何聆听Control.IsEnable
状态并将PreviousControl
显示为第一项(如果启用)并将NextControl
作为最后一项(如果启用),那将会非常棒。
谢谢
你需要一个'CollectionView'(可能是一个'CompositeCollection',因为你的Previous和Next元素将会是一个不同于其他项的类型),还有一个'RoutedCommand'来处理前一个/下一个逻辑和启用/禁用。 – 2015-01-15 15:39:51