ListBoxPage.xaml 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <UserControl xmlns="https://github.com/avaloniaui"
  2. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  3. x:Class="ControlCatalog.Pages.ListBoxPage">
  4. <DockPanel>
  5. <DockPanel.Styles>
  6. <Style Selector="ListBox ListBoxItem:nth-child(5n+3)">
  7. <Setter Property="Foreground" Value="Red" />
  8. <Setter Property="FontWeight" Value="Bold" />
  9. </Style>
  10. <Style Selector="ListBox ListBoxItem:nth-last-child(5n+4)">
  11. <Setter Property="Foreground" Value="Blue" />
  12. <Setter Property="FontWeight" Value="Bold" />
  13. </Style>
  14. </DockPanel.Styles>
  15. <StackPanel DockPanel.Dock="Top" Margin="4">
  16. <TextBlock Classes="h2">Hosts a collection of ListBoxItem.</TextBlock>
  17. <TextBlock Classes="h2">Each 5th item is highlighted with nth-child(5n+3) and nth-last-child(5n+4) rules.</TextBlock>
  18. </StackPanel>
  19. <StackPanel DockPanel.Dock="Right" Margin="4">
  20. <CheckBox IsChecked="{Binding Multiple}">Multiple</CheckBox>
  21. <CheckBox IsChecked="{Binding Toggle}">Toggle</CheckBox>
  22. <CheckBox IsChecked="{Binding AlwaysSelected}">AlwaysSelected</CheckBox>
  23. <CheckBox IsChecked="{Binding AutoScrollToSelectedItem}">AutoScrollToSelectedItem</CheckBox>
  24. <CheckBox IsChecked="{Binding WrapSelection}">WrapSelection</CheckBox>
  25. </StackPanel>
  26. <StackPanel DockPanel.Dock="Bottom" Orientation="Horizontal" Margin="4">
  27. <Button Command="{Binding AddItemCommand}">Add</Button>
  28. <Button Command="{Binding RemoveItemCommand}">Remove</Button>
  29. <Button Command="{Binding SelectRandomItemCommand}">Select Random Item</Button>
  30. </StackPanel>
  31. <ListBox Items="{Binding Items}"
  32. Selection="{Binding Selection}"
  33. AutoScrollToSelectedItem="{Binding AutoScrollToSelectedItem}"
  34. SelectionMode="{Binding SelectionMode^}"
  35. WrapSelection="{Binding WrapSelection}"/>
  36. </DockPanel>
  37. </UserControl>