aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Touch/Controls/TouchListBox.xaml
blob: 61342fc0bc2a8f91e10753f84e6357cc3691c3eb (plain)
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
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:components="clr-namespace:Tango.Touch.Components"
                    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
                    xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI"
                    xmlns:localConverters="clr-namespace:Tango.Touch.Converters"
                    xmlns:local="clr-namespace:Tango.Touch.Controls">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="../Resources/Colors.xaml" />

        <ResourceDictionary>
            <localConverters:SelectionModesToBooleanConverter x:Key="SelectionModesToBooleanConverter" />
        </ResourceDictionary>
    </ResourceDictionary.MergedDictionaries>

    <Style TargetType="{x:Type local:TouchListBox}">
        <Setter Property="local:TouchPanel.PreventFocusSteal" Value="True"></Setter>
        <Setter Property="ItemContainerStyle">
            <Setter.Value>
                <Style TargetType="local:TouchListBoxItem">
                    <Setter Property="Background" Value="Transparent"></Setter>
                    <Style.Triggers>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding RelativeSource={RelativeSource Self},Path=IsSelected}" Value="True" />
                                <Condition Binding="{Binding RelativeSource={RelativeSource AncestorType=local:TouchListBox},Path=SelectionMode,Converter={StaticResource SelectionModesToBooleanConverter},ConverterParameter='Single,Multiple'}" Value="True" />
                            </MultiDataTrigger.Conditions>
                            <Setter Property="Background" Value="{StaticResource TangoLightSelectedBrush}"></Setter>
                        </MultiDataTrigger>
                    </Style.Triggers>
                </Style>
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:TouchListBox}">
                    <Border  BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="true">
                        <local:LightTouchScrollViewer x:Name="PART_ScrollViewer" ScrollBarVisibility="{TemplateBinding ScrollBarVisibility}" DisableScrolling="{TemplateBinding DisableScrolling}">
                            <ItemsControl VirtualizingPanel.IsVirtualizing="False" x:Name="PART_ItemsControl" Style="{x:Null}" ItemsSource="{TemplateBinding ItemsSource}" VerticalAlignment="Top" ClipToBounds="True">
                                <ItemsControl.ItemsPanel>
                                    <ItemsPanelTemplate>
                                        <StackPanel  Orientation="Vertical" VerticalAlignment="Top" />
                                    </ItemsPanelTemplate>
                                </ItemsControl.ItemsPanel>
                                <ItemsControl.ItemTemplate>
                                    <DataTemplate>
                                        <local:TouchListBoxItem Style="{Binding RelativeSource={RelativeSource AncestorType=local:TouchListBox},Path=ItemContainerStyle}">
                                            <i:Interaction.Triggers>
                                                <i:EventTrigger EventName="Loaded">
                                                    <i:InvokeCommandAction Command="{Binding RelativeSource={RelativeSource AncestorType=local:TouchListBox},Path=ListBoxItemLoadedCommand}" CommandParameter="{Binding RelativeSource={RelativeSource AncestorType=local:TouchListBoxItem}}" />
                                                </i:EventTrigger>
                                            </i:Interaction.Triggers>
                                            <components:Ripple RippleBrush="{StaticResource TangoRippleDarkBrush}" RippleFactor="30">
                                                <components:Ripple.Style>
                                                    <Style TargetType="components:Ripple">
                                                        <Setter Property="Disabled" Value="False"></Setter>
                                                        <Style.Triggers>
                                                            <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=local:TouchListBox},Path=ScrollViewer.IsScrolling}" Value="True">
                                                                <Setter Property="Disabled" Value="True"></Setter>
                                                            </DataTrigger>
                                                            <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=local:TouchListBox},Path=IsMultiSelecting}" Value="True">
                                                                <Setter Property="Disabled" Value="True"></Setter>
                                                            </DataTrigger>
                                                            <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=local:TouchListBox},Path=DisableRipple}" Value="True">
                                                                <Setter Property="Disabled" Value="True"></Setter>
                                                            </DataTrigger>
                                                        </Style.Triggers>
                                                    </Style>
                                                </components:Ripple.Style>
                                                <ContentControl Content="{Binding}" ContentTemplate="{Binding RelativeSource={RelativeSource AncestorType=local:TouchListBox},Path=ItemTemplate}" />
                                            </components:Ripple>
                                        </local:TouchListBoxItem>
                                    </DataTemplate>
                                </ItemsControl.ItemTemplate>
                            </ItemsControl>
                        </local:LightTouchScrollViewer>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>