aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Touch/Components/Ripple.xaml
blob: e64a10057435f3eff491b09ea8ec0a53a58e6270 (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
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
                    xmlns:converters="clr-namespace:Tango.Touch.Converters"
                    xmlns:local="clr-namespace:Tango.Touch.Components">

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

        <ResourceDictionary>
            <converters:WidthHeightToRectConverter x:Key="WidthHeightToRectConverter" />
        </ResourceDictionary>
    </ResourceDictionary.MergedDictionaries>

    <Style TargetType="{x:Type local:Ripple}">
        <Setter Property="ClipToBounds" Value="True"></Setter>
        <Setter Property="Background" Value="Transparent"></Setter>
        <Setter Property="RippleBrush" Value="{StaticResource TangoRippleLightBrush}"></Setter>
        <Setter Property="HorizontalAlignment" Value="Stretch"></Setter>
        <Setter Property="VerticalAlignment" Value="Stretch"></Setter>
        <Setter Property="IsHitTestVisible" Value="True"></Setter>
        <Setter Property="Focusable" Value="False"></Setter>
        <Setter Property="FocusVisualStyle" Value="{x:Null}"></Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:Ripple}">
                    <Border CornerRadius="{TemplateBinding CornerRadius}">
                        <Border.Clip>
                            <RectangleGeometry RadiusX="{Binding RelativeSource={RelativeSource AncestorType=local:Ripple},Path=CornerRadius.TopLeft}" RadiusY="{Binding RelativeSource={RelativeSource AncestorType=local:Ripple},Path=CornerRadius.BottomRight}">
                                <RectangleGeometry.Rect>
                                    <MultiBinding Converter="{StaticResource WidthHeightToRectConverter}">
                                        <Binding RelativeSource="{RelativeSource AncestorType=local:Ripple}" Path="ActualWidth" />
                                        <Binding RelativeSource="{RelativeSource AncestorType=local:Ripple}" Path="ActualHeight" />
                                    </MultiBinding>
                                </RectangleGeometry.Rect>
                            </RectangleGeometry>
                        </Border.Clip>
                        <Grid x:Name="PART_grid">
                            <Canvas IsHitTestVisible="False">
                                <Ellipse IsHitTestVisible="False" x:Name="PART_ellipse" RenderTransformOrigin="0.5,0.5" Fill="{TemplateBinding RippleBrush}" HorizontalAlignment="Center" VerticalAlignment="Center" Height="{TemplateBinding ActualHeight}" Width="{TemplateBinding ActualHeight}">
                                    <Ellipse.RenderTransform>
                                        <ScaleTransform x:Name="PART_scale" ScaleX="0" ScaleY="0"></ScaleTransform>
                                    </Ellipse.RenderTransform>
                                </Ellipse>
                            </Canvas>
                            <ContentPresenter Content="{TemplateBinding Content}" />
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>