MultiSelectComboBox.xaml 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <UserControl x:Class="GDNXFD.Alert.Config.Controls.MultiSelectComboBox"
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. >
  5. <ComboBox
  6. x:Name="MultiSelectCombo"
  7. SnapsToDevicePixels="True"
  8. OverridesDefaultStyle="True"
  9. ScrollViewer.HorizontalScrollBarVisibility="Auto"
  10. ScrollViewer.VerticalScrollBarVisibility="Auto"
  11. ScrollViewer.CanContentScroll="True"
  12. IsSynchronizedWithCurrentItem="True"
  13. >
  14. <ComboBox.ItemTemplate>
  15. <DataTemplate>
  16. <CheckBox Content="{Binding Title}"
  17. IsChecked="{Binding Path=IsSelected, Mode=TwoWay}"
  18. Tag="{RelativeSource FindAncestor, AncestorType={x:Type ComboBox}}"
  19. Click="CheckBox_Click" />
  20. </DataTemplate>
  21. </ComboBox.ItemTemplate>
  22. <ComboBox.Template>
  23. <ControlTemplate TargetType="ComboBox">
  24. <Grid >
  25. <ToggleButton
  26. x:Name="ToggleButton"
  27. Grid.Column="2" IsChecked="{Binding Path=IsDropDownOpen,Mode=TwoWay,RelativeSource={RelativeSource TemplatedParent}}"
  28. Focusable="false"
  29. ClickMode="Press" HorizontalContentAlignment="Left" >
  30. <ToggleButton.Template>
  31. <ControlTemplate>
  32. <Grid>
  33. <Grid.ColumnDefinitions>
  34. <ColumnDefinition Width="*"/>
  35. <ColumnDefinition Width="18"/>
  36. </Grid.ColumnDefinitions>
  37. <Border
  38. x:Name="Border"
  39. Grid.ColumnSpan="2"
  40. CornerRadius="2"
  41. Background="White"
  42. BorderBrush="Black"
  43. BorderThickness="1,1,1,1" />
  44. <Border
  45. x:Name="BorderComp"
  46. Grid.Column="0"
  47. CornerRadius="2"
  48. Margin="1"
  49. Background="White"
  50. BorderBrush="Black"
  51. BorderThickness="0,0,0,0" >
  52. <TextBlock Text="{Binding Path=Text,RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}"
  53. Background="White" Padding="3" />
  54. </Border>
  55. <Path
  56. x:Name="Arrow"
  57. Grid.Column="1"
  58. Fill="Black"
  59. HorizontalAlignment="Center"
  60. VerticalAlignment="Center"
  61. Data="M 0 0 L 4 4 L 8 0 Z"/>
  62. </Grid>
  63. </ControlTemplate>
  64. </ToggleButton.Template>
  65. </ToggleButton>
  66. <Popup
  67. Name="Popup"
  68. Placement="Bottom"
  69. AllowsTransparency="True"
  70. Focusable="False" IsOpen="{TemplateBinding IsDropDownOpen}"
  71. PopupAnimation="Slide">
  72. <Grid
  73. Name="DropDown"
  74. SnapsToDevicePixels="True"
  75. MinWidth="{TemplateBinding ActualWidth}"
  76. MaxHeight="{TemplateBinding MaxDropDownHeight}">
  77. <Border
  78. x:Name="DropDownBorder"
  79. BorderThickness="1" Background="White"
  80. BorderBrush="Black"/>
  81. <ScrollViewer Margin="4,6,4,6" SnapsToDevicePixels="True" DataContext="{Binding}">
  82. <StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Contained" />
  83. </ScrollViewer>
  84. </Grid>
  85. </Popup>
  86. </Grid>
  87. <ControlTemplate.Triggers>
  88. <Trigger Property="HasItems" Value="false">
  89. <Setter TargetName="DropDownBorder" Property="MinHeight" Value="95"/>
  90. </Trigger>
  91. <Trigger SourceName="Popup" Property="Popup.AllowsTransparency" Value="true">
  92. <Setter TargetName="DropDownBorder" Property="CornerRadius" Value="4"/>
  93. <Setter TargetName="DropDownBorder" Property="Margin" Value="0,2,0,0"/>
  94. </Trigger>
  95. </ControlTemplate.Triggers>
  96. </ControlTemplate>
  97. </ComboBox.Template>
  98. </ComboBox>
  99. </UserControl>