1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:fa="http://schemas.fontawesome.io/icons/"
xmlns:local="clr-namespace:Tango.SharedUI.Controls">
<Style TargetType="{x:Type local:MultiSelectComboBox}">
<Setter Property="Background" Value="Transparent"></Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:MultiSelectComboBox}">
<Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="3" >
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<ToggleButton x:Name="MultiSelToggleButton" Grid.Column="0" MinHeight="40" Height="Auto"
VerticalAlignment="Center"
HorizontalAlignment="Stretch" Margin="4,0,0,0" SnapsToDevicePixels="True"
Foreground="{TemplateBinding Foreground}" BorderBrush="{TemplateBinding BorderBrush}"
IsChecked="{Binding RelativeSource={RelativeSource AncestorType=local:MultiSelectComboBox}, Path=IsToggleChecked,Mode=TwoWay}">
<ToggleButton.Template>
<ControlTemplate TargetType="ToggleButton">
<Grid >
<WrapPanel>
<ItemsControl x:Name="SelectedItems" ItemsSource="{Binding RelativeSource={RelativeSource AncestorType=local:MultiSelectComboBox}, Path=SelectedItemsList}">
<ItemsControl.Template>
<ControlTemplate TargetType="{x:Type ItemsControl}">
<ItemsPresenter HorizontalAlignment="Stretch" />
</ControlTemplate>
</ItemsControl.Template>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel IsItemsHost="True" Orientation="Horizontal" VerticalAlignment="Top" HorizontalAlignment="Left"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Button Margin="4,2" Height="25" Width="Auto" Background="Transparent" BorderThickness="0.5" BorderBrush="{Binding RelativeSource={RelativeSource AncestorType=local:MultiSelectComboBox}, Path=BorderBrush}"
Command="{Binding RelativeSource={RelativeSource AncestorType=local:MultiSelectComboBox}, Path=RemoveItemCommand}" CommandParameter="{Binding}">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding}" VerticalAlignment="Center" />
<fa:ImageAwesome Icon="Close" Width="12" Margin="2" VerticalAlignment="Center" HorizontalAlignment="Right" RenderTransformOrigin="0.5,0.5"/>
</StackPanel>
</Button>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<TextBox x:Name="Edit_PART" Height="25" VerticalAlignment="Top" BorderBrush="Transparent" VerticalContentAlignment="Center" BorderThickness="0"
Text="{Binding RelativeSource={RelativeSource AncestorType=local:MultiSelectComboBox},Path=SearchText, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Margin="2"></TextBox>
</WrapPanel>
</Grid>
</ControlTemplate>
</ToggleButton.Template>
</ToggleButton>
<Button Grid.Column=" 1" BorderBrush="Transparent" Opacity="0.05" VerticalContentAlignment="Top" Command="{Binding RelativeSource={RelativeSource AncestorType=local:MultiSelectComboBox}, Path=RemoveAllCommand}">
<fa:ImageAwesome Icon="Times" Width="12" Foreground="{TemplateBinding Foreground}" Margin="10" VerticalAlignment="Top">
</fa:ImageAwesome>
<Button.Style>
<Style TargetType="Button">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border Background="{TemplateBinding Background}">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderBrush" Value="Transparent"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="False">
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderBrush" Value="Transparent"/>
</Trigger>
<EventTrigger RoutedEvent="Control.MouseEnter">
<BeginStoryboard>
<Storyboard >
<DoubleAnimation Duration="0:0:1" To="1" Storyboard.TargetProperty="Opacity"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
<EventTrigger RoutedEvent="Control.MouseLeave">
<BeginStoryboard>
<Storyboard >
<DoubleAnimation Duration="0:0:1" To="0.05" Storyboard.TargetProperty="Opacity"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Style.Triggers>
</Style>
</Button.Style>
</Button>
<Popup x:Name="MultiSel_Popup" Tag="{Binding RelativeSource={RelativeSource AncestorType=local:MultiSelectComboBox}}" MinHeight="25" MaxHeight="600" HorizontalOffset="0" MinWidth="{TemplateBinding ActualWidth}" MaxWidth="800" Grid.ColumnSpan="2"
PlacementTarget="{Binding ElementName=MultiSelToggleButton}" Placement="Bottom" AllowsTransparency="True"
IsOpen="{Binding RelativeSource={RelativeSource Self},Path=Tag.IsToggleChecked,Mode=TwoWay}" PopupAnimation="Slide" >
<Border Opacity="1" Background="{TemplateBinding Background}" Padding="3" BorderThickness="1" BorderBrush="Beige">
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Hidden">
<ItemsControl x:Name="PropertyDisplay" ItemsSource="{Binding RelativeSource={RelativeSource AncestorType=local:MultiSelectComboBox}, Path=SearchItemsList}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Button Margin="4,2" Height="Auto" Width="Auto" Background="Transparent" BorderThickness="0.5" BorderBrush="{Binding RelativeSource={RelativeSource AncestorType=local:MultiSelectComboBox}, Path=BorderBrush}"
Command="{Binding RelativeSource={RelativeSource AncestorType=local:MultiSelectComboBox}, Path=AddItemCommand}" CommandParameter="{Binding}">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding}" VerticalAlignment="Center" />
</StackPanel>
</Button>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</Border>
</Popup>
</Grid>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
|