<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Controls="clr-namespace:RadialMenu.Controls">

    <Style TargetType="Controls:RadialMenu">

        <Style.Triggers>
            <Trigger Property="IsOpen" Value="True">

                <!-- RadialMenu openning animation -->
                <Trigger.EnterActions>
                    <BeginStoryboard>
                        <Storyboard>
                            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity">
                                <SplineDoubleKeyFrame KeyTime="0:0:0.75" KeySpline="0.4,1,0.1,1" Value="1"/>
                            </DoubleAnimationUsingKeyFrames>
                            <DoubleAnimationUsingKeyFrames
                                    Storyboard.TargetProperty="RenderTransform.Children[0].ScaleX">
                                <SplineDoubleKeyFrame KeyTime="0:0:0.75" KeySpline="0.4,1,0.1,1" Value="1"/>
                            </DoubleAnimationUsingKeyFrames>
                            <DoubleAnimationUsingKeyFrames
                                    Storyboard.TargetProperty="RenderTransform.Children[0].ScaleY">
                                <SplineDoubleKeyFrame KeyTime="0:0:0.75" KeySpline="0.4,1,0.1,1" Value="1"/>
                            </DoubleAnimationUsingKeyFrames>
                            <DoubleAnimationUsingKeyFrames
                                    Storyboard.TargetProperty="RenderTransform.Children[1].Angle">
                                <SplineDoubleKeyFrame KeyTime="0:0:0.75" KeySpline="0.4,1,0.1,1" Value="0"/>
                            </DoubleAnimationUsingKeyFrames>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility">
                                <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{x:Static Visibility.Visible}"/>
                            </ObjectAnimationUsingKeyFrames>
                        </Storyboard>
                    </BeginStoryboard>
                </Trigger.EnterActions>

                <!-- RadialMenu closing animation -->
                <Trigger.ExitActions>
                    <BeginStoryboard>
                        <Storyboard>
                            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity">
                                <SplineDoubleKeyFrame KeyTime="0:0:0.75" KeySpline="0.4,1,0.1,1" Value="0"/>
                            </DoubleAnimationUsingKeyFrames>
                            <DoubleAnimationUsingKeyFrames
                                    Storyboard.TargetProperty="RenderTransform.Children[0].ScaleX">
                                <SplineDoubleKeyFrame KeyTime="0:0:0.75" KeySpline="0.4,1,0.1,1" Value="0.5"/>
                            </DoubleAnimationUsingKeyFrames>
                            <DoubleAnimationUsingKeyFrames
                                    Storyboard.TargetProperty="RenderTransform.Children[0].ScaleY">
                                <SplineDoubleKeyFrame KeyTime="0:0:0.75" KeySpline="0.4,1,0.1,1" Value="0.5"/>
                            </DoubleAnimationUsingKeyFrames>
                            <DoubleAnimationUsingKeyFrames
                                    Storyboard.TargetProperty="RenderTransform.Children[1].Angle">
                                <SplineDoubleKeyFrame KeyTime="0:0:0.75" KeySpline="0.4,1,0.1,1" Value="-50"/>
                            </DoubleAnimationUsingKeyFrames>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility">
                                <DiscreteObjectKeyFrame KeyTime="0:0:0.4" Value="{x:Static Visibility.Collapsed}"/>
                            </ObjectAnimationUsingKeyFrames>
                        </Storyboard>
                    </BeginStoryboard>
                </Trigger.ExitActions>

            </Trigger>
        </Style.Triggers>

        <!-- Default RadialMenu style (while closed) -->
        <Setter Property="Opacity" Value="0"/>
        <Setter Property="Visibility" Value="Collapsed"/>
        <Setter Property="Height" Value="300"/>
        <Setter Property="Width" Value="300"/>
        <Setter Property="RenderTransform">
            <Setter.Value>
                <TransformGroup>
                    <ScaleTransform CenterX="150" CenterY="150" ScaleX="0.5" ScaleY="0.5"/>
                    <RotateTransform CenterX="150" CenterY="150" Angle="-50"/>
                </TransformGroup>
            </Setter.Value>
        </Setter>

        <!-- RadialMenu template -->
        <Setter Property="Template">
            <Setter.Value>

                <ControlTemplate TargetType="Controls:RadialMenu">
                    <Grid>

                        <!-- RadialMenu background -->
                        <Ellipse Fill="{TemplateBinding Background}" Width="{TemplateBinding Width}" Height="{TemplateBinding Height}"/>

                        <!-- Content repitition (for items around) -->
                        <ItemsControl ItemsSource="{TemplateBinding Content}">
                            <ItemsControl.ItemsPanel>
                                <ItemsPanelTemplate>
                                    <Grid/>
                                </ItemsPanelTemplate>
                            </ItemsControl.ItemsPanel>
                        </ItemsControl>

                        <!-- Content (for central item) -->
                        <ContentPresenter Content="{TemplateBinding CentralItem}"/>

                    </Grid>
                </ControlTemplate>

            </Setter.Value>
        </Setter>

    </Style>

</ResourceDictionary>
