Define OpenAnimation and CloseAnimation in Style

Topics: question
Nov 29, 2010 at 9:09 PM

Hi there,

first of all nice work this toolkit code, well done! Now to my issue - I've decided to create a generic ToolTip style throughout the application and I'm struggling to assign the OpenAnimation (not really tried the CloseAnimation, but I'm expecting it to behave the same) in Style because the StoryBoard.TargetName is not resolving - dont really have anything to put there as the style itself is without a name or key (supposed to be generic) and even thought I'm overriding the Template, it's not picking up the names from there... 

 

Any Ideas?

 

Regards,

Stevo

Coordinator
Dec 2, 2010 at 9:05 AM

Hi Stevo,

Could you please paste me your style xaml so I can investigate your specific issue?

Thanks!

Best regards,

Xavier

Dec 2, 2010 at 10:46 AM

Hi Xavier,

 

I could, once I get home, however there is no point really, I made it up and it doesn't work.... The question is, can you create a ToolTip Style with the OpenAnimation defined and working?

 

Best Regards,

Stevo

Mar 15, 2011 at 8:40 AM

Has any1 been able to solve this issue?

You'd expect this to work, but the

Storyboard.TargetName=

in the storyboard causes issues

Code sample:

    <Style TargetType="customToolips:ToolTip">
        <Setter Property="Background" Value="{StaticResource InnerFill}"/>
        <Setter Property="Foreground" Value="{StaticResource ControlForeground}"/>
        <Setter Property="Padding" Value="3,0,3,0"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="BorderBrush" Value="{StaticResource ControlBorder}"/>
        <Setter Property="Placement" Value="Bottom"/>
        <Setter Property="InitialDelay" Value="00:00:00.5"/>
        <Setter Property="Opacity" Value="0"/>
        <Setter Property="RenderTransformOrigin" Value="0.5,0.5"/>
        <Setter Property="RenderTransform">
            <Setter.Value>
                <CompositeTransform ScaleX="0" ScaleY="0"/>
            </Setter.Value>
        </Setter>
        <Setter Property="Effect">
            <Setter.Value>
                <DropShadowEffect Color="#44000000" ShadowDepth="0" BlurRadius="0" Direction="-45" Opacity="0.5"/>
            </Setter.Value>            
        </Setter>
        <Setter Property="OpenAnimation">
            <Setter.Value>
                <Storyboard>
                    <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="tooltipControl"/>
                    <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleX)" Storyboard.TargetName="tooltipControl">
                        <EasingDoubleKeyFrame KeyTime="0:0:0.15" Value="1.5"/>
                        <EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="1"/>
                    </DoubleAnimationUsingKeyFrames>
                    <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleY)" Storyboard.TargetName="tooltipControl">
                        <EasingDoubleKeyFrame KeyTime="0:0:0.15" Value="1.5"/>
                        <EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="1"/>
                    </DoubleAnimationUsingKeyFrames>
                    <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Effect).(DropShadowEffect.BlurRadius)" Storyboard.TargetName="tooltipControl">
                        <EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="0"/>
                        <EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="15"/>
                    </DoubleAnimationUsingKeyFrames>
                    <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Effect).(DropShadowEffect.ShadowDepth)" Storyboard.TargetName="tooltipControl">
                        <EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="0"/>
                        <EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="20"/>
                    </DoubleAnimationUsingKeyFrames>
                </Storyboard>
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="customToolips:ToolTip">
                    <Border x:Name="tooltipControl" CornerRadius="7" Opacity="1" BorderThickness="{TemplateBinding BorderThickness}" Background="{StaticResource ControlBackground}" BorderBrush="{TemplateBinding BorderBrush}">
                        <Border BorderBrush="{StaticResource InnerStroke}" Margin="3" BorderThickness="1" CornerRadius="5" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}">
                            <ContentPresenter
                              Content="{TemplateBinding Content}"
                              ContentTemplate="{TemplateBinding ContentTemplate}"
                              Cursor="{TemplateBinding Cursor}"
                              Margin="{TemplateBinding Padding}"/>
                        </Border>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>