-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathPopupEnumFilter.xaml
88 lines (85 loc) · 5.59 KB
/
PopupEnumFilter.xaml
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
<Control x:Name="Control" x:Class="WPF_dnscrypt_proxy_md.PopupEnumFilter"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:WPF_dnscrypt_proxy_md"
mc:Ignorable="d"
xmlns:dgx="clr-namespace:DataGridExtensions;assembly=DataGridExtensions"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit">
<Control.Resources>
<Style TargetType="Popup" x:Key="ShowProtocolFilter">
<Style.Triggers>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding Path=IsChecked, ElementName=button}" Value="True" />
<Condition Binding="{Binding Path=Column.SortMemberPath, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGridColumnHeader}}" Value="STAMP.Proto" />
</MultiDataTrigger.Conditions>
<Setter Property="IsOpen" Value="True" />
</MultiDataTrigger>
<DataTrigger Binding="{Binding Path=IsChecked, ElementName=button}" Value="False">
<Setter Property="IsOpen" Value="False" />
</DataTrigger>
</Style.Triggers>
</Style>
<Style TargetType="Popup" x:Key="ShowFlagsFilter">
<Style.Triggers>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding Path=IsChecked, ElementName=button}" Value="True" />
<Condition Binding="{Binding Path=Column.SortMemberPath, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGridColumnHeader}}" Value="STAMP.Props" />
</MultiDataTrigger.Conditions>
<Setter Property="IsOpen" Value="True" />
</MultiDataTrigger>
<DataTrigger Binding="{Binding Path=IsChecked, ElementName=button}" Value="False">
<Setter Property="IsOpen" Value="False" />
</DataTrigger>
</Style.Triggers>
</Style>
</Control.Resources>
<Control.Template>
<ControlTemplate>
<Grid>
<ToggleButton x:Name="button">
<ToggleButton.Style>
<Style TargetType="Control">
<!-- Only show the button if the filter is active or if the mouse is over the column header -->
<Style.Triggers>
<DataTrigger Binding="{Binding Path=Filter, ElementName=Control}" Value="{x:Null}">
<Setter Property="Visibility" Value="Hidden"/>
</DataTrigger>
<DataTrigger Binding="{Binding Path=IsMouseOver, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGridColumnHeader}}" Value="True">
<Setter Property="Visibility" Value="Visible"/>
</DataTrigger>
</Style.Triggers>
</Style>
</ToggleButton.Style>
<!-- Reuse the standard icon, but change color to green -->
<Control Style="{DynamicResource {x:Static dgx:DataGridFilter.IconStyleKey}}" Foreground="Green"/>
</ToggleButton>
<Popup x:Name="Flags" Style="{StaticResource ShowFlagsFilter}" AllowsTransparency="True"
DataContext="{Binding ElementName=Control}" StaysOpen="False">
<Border Background="White" BorderBrush="Gray" BorderThickness="1" CornerRadius="3" Padding="4">
<StackPanel>
<TextBlock Text="Select Flags Filter:" Margin="0,3"/>
<xctk:CheckComboBox Delimiter=" | " BorderThickness="0" DisplayMemberPath="Value" ValueMemberPath="Key"
ItemsSource="{Binding Source={local:EnumList {x:Type local:ServerFlag}, AsString=True, DBNull=False}}"
SelectedItemsOverride="{Binding FlagsValue, Mode=TwoWay, Converter={local:EnumConverter}, ConverterParameter={x:Type local:ServerFlag}}"/>
</StackPanel>
</Border>
</Popup>
<Popup x:Name="Protocol" Style="{StaticResource ShowProtocolFilter}" AllowsTransparency="True"
DataContext="{Binding ElementName=Control}" StaysOpen="False">
<Border Background="White" BorderBrush="Gray" BorderThickness="1" CornerRadius="3" Padding="4">
<StackPanel>
<TextBlock Text="Select Protocol Filter:" Margin="0,3"/>
<xctk:CheckComboBox BorderThickness="0" DisplayMemberPath="Value" ValueMemberPath="Key"
ItemsSource="{Binding Source={local:EnumList {x:Type local:Protocol}, AsString=True, DBNull=False}}"
SelectedItemsOverride="{Binding ProtocolValue, Mode=TwoWay, Converter={local:EnumConverter}, ConverterParameter={x:Type local:Protocol}}"/>
</StackPanel>
</Border>
</Popup>
</Grid>
</ControlTemplate>
</Control.Template>
</Control>