ShakersView.xaml 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <UserControl
  2. x:Class="ShakerManger.View.ShakersView"
  3. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  4. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  5. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  6. xmlns:local="clr-namespace:ShakerManger.View"
  7. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  8. xmlns:vm="clr-namespace:ShakerManger.ViewModel"
  9. d:DataContext="{d:DesignInstance {x:Type vm:ShakersViewModel}}"
  10. d:DesignHeight="450"
  11. d:DesignWidth="800"
  12. DataContext="{Binding Source={StaticResource MainViewModel}, Path=Data.MainPages[0]}"
  13. mc:Ignorable="d">
  14. <UserControl.ContextMenu>
  15. <ContextMenu>
  16. <MenuItem
  17. Name="Auto"
  18. Command="{Binding AutoLayoutCommand}"
  19. FontSize="14"
  20. Header="自动布局" />
  21. </ContextMenu>
  22. </UserControl.ContextMenu>
  23. <ListView Grid.Column="1" ItemsSource="{Binding LayoutShakers}">
  24. <ListView.Style>
  25. <Style TargetType="ListView" BasedOn="{x:Null}">
  26. <Setter Property="Background" Value="Transparent" />
  27. <Setter Property="BorderBrush" Value="Transparent" />
  28. <Setter Property="VerticalContentAlignment" Value="Stretch" />
  29. <Setter Property="Padding" Value="0" />
  30. <Setter Property="Template">
  31. <Setter.Value>
  32. <ControlTemplate TargetType="ListView">
  33. <ItemsPresenter Margin="0" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
  34. </ControlTemplate>
  35. </Setter.Value>
  36. </Setter>
  37. <Setter Property="ItemTemplate">
  38. <Setter.Value>
  39. <DataTemplate>
  40. <ContentControl Content="{Binding Content}" />
  41. </DataTemplate>
  42. </Setter.Value>
  43. </Setter>
  44. <Setter Property="ItemContainerStyle">
  45. <Setter.Value>
  46. <Style TargetType="ListViewItem">
  47. <Setter Property="Background" Value="Transparent" />
  48. <Setter Property="BorderBrush" Value="Transparent" />
  49. <Setter Property="BorderThickness" Value="0" />
  50. <Setter Property="SnapsToDevicePixels" Value="True" />
  51. <Setter Property="OverridesDefaultStyle" Value="True" />
  52. <Setter Property="Cursor" Value="Hand" />
  53. <Setter Property="IsEnabled" Value="True" />
  54. <Setter Property="Padding" Value="0" />
  55. <Setter Property="Template">
  56. <Setter.Value>
  57. <ControlTemplate TargetType="ListViewItem">
  58. <ContentPresenter
  59. Margin="4"
  60. Content="{TemplateBinding Content}"
  61. ContentStringFormat="{TemplateBinding ContentStringFormat}"
  62. ContentTemplate="{TemplateBinding ContentTemplate}"
  63. ContentTemplateSelector="{x:Null}" />
  64. </ControlTemplate>
  65. </Setter.Value>
  66. </Setter>
  67. </Style>
  68. </Setter.Value>
  69. </Setter>
  70. <Setter Property="ItemsPanel">
  71. <Setter.Value>
  72. <ItemsPanelTemplate>
  73. <UniformGrid
  74. Margin="0"
  75. Columns="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ListView}, Path=DataContext.Layout.ColumnCount}"
  76. Rows="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ListView}, Path=DataContext.Layout.RowCount}"
  77. Style="{x:Null}" />
  78. </ItemsPanelTemplate>
  79. </Setter.Value>
  80. </Setter>
  81. </Style>
  82. </ListView.Style>
  83. </ListView>
  84. </UserControl>