tags:

views:

179

answers:

1

I have these buttons that contain images right, that have a drop-shadow effect, the opacity of which varies, depending on whether you are mousing over them or not. I have these buttons inside a wrap panel (and in one case, a stack panel). Now, (only on my home computer, not my laptop!), if I hover over a button that is not on the end of the panel, it runs away, hiding (mostly) behind the next button along!

I did some testing on this, and found out that it's the image element moving (or the content presenter, not sure at which level...). I'm wondering if it's the computer (I have some trouble with the menus in Expression Blend), but I'm open to all suggestions. Any advice??? This is really weird!

Here are the relevant styles & storyboards:

<ResourceDictionary>
     <Storyboard x:Key="DropShadow_Opac45">
      <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="contentPresenter" Storyboard.TargetProperty="(UIElement.Opacity)">
       <SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="1"/>
      </DoubleAnimationUsingKeyFrames>
      <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="contentPresenter" Storyboard.TargetProperty="(UIElement.Effect).(DropShadowEffect.Opacity)">
       <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
       <SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="0.45"/>
      </DoubleAnimationUsingKeyFrames>
     </Storyboard>
     <Storyboard x:Key="DropShadow_Opac45_Reverse">
      <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="contentPresenter" Storyboard.TargetProperty="(UIElement.Opacity)">
       <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
       <SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="0.8"/>
      </DoubleAnimationUsingKeyFrames>
      <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="contentPresenter" Storyboard.TargetProperty="(UIElement.Effect).(DropShadowEffect.Opacity)">
       <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0.45"/>
       <SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="0"/>
      </DoubleAnimationUsingKeyFrames>
     </Storyboard>
     <Storyboard x:Key="DropShadow_Opac80">
      <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="contentPresenter" Storyboard.TargetProperty="(UIElement.Opacity)">
       <SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="1"/>
      </DoubleAnimationUsingKeyFrames>
      <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="contentPresenter" Storyboard.TargetProperty="(UIElement.Effect).(DropShadowEffect.Opacity)">
       <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
       <SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="0.8"/>
      </DoubleAnimationUsingKeyFrames>
     </Storyboard>
     <Storyboard x:Key="DropShadow_Opac80_Reverse">
      <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="contentPresenter" Storyboard.TargetProperty="(UIElement.Opacity)">
       <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
       <SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="0.8"/>
      </DoubleAnimationUsingKeyFrames>
      <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="contentPresenter" Storyboard.TargetProperty="(UIElement.Effect).(DropShadowEffect.Opacity)">
       <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0.8"/>
       <SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="0"/>
      </DoubleAnimationUsingKeyFrames>
     </Storyboard>
     <Style x:Key="HoverPanelButton" TargetType="{x:Type Button}">
      <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
      <Setter Property="HorizontalContentAlignment" Value="Center"/>
      <Setter Property="VerticalContentAlignment" Value="Center"/>
      <Setter Property="Template">
       <Setter.Value>
        <ControlTemplate TargetType="{x:Type Button}">
         <ControlTemplate.Resources>
          <Storyboard x:Key="DropShadow_Opac45">
           <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="contentPresenter" Storyboard.TargetProperty="(UIElement.Opacity)">
            <SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="1"/>
           </DoubleAnimationUsingKeyFrames>
           <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="contentPresenter" Storyboard.TargetProperty="(UIElement.Effect).(DropShadowEffect.Opacity)">
            <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
            <SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="0.45"/>
           </DoubleAnimationUsingKeyFrames>
          </Storyboard>
          <Storyboard x:Key="DropShadow_Opac45_Reverse">
           <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="contentPresenter" Storyboard.TargetProperty="(UIElement.Opacity)">
            <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
            <SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="0.8"/>
           </DoubleAnimationUsingKeyFrames>
           <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="contentPresenter" Storyboard.TargetProperty="(UIElement.Effect).(DropShadowEffect.Opacity)">
            <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0.45"/>
            <SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="0"/>
           </DoubleAnimationUsingKeyFrames>
          </Storyboard>
          <Storyboard x:Key="DropShadow_Opac80">
           <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="contentPresenter" Storyboard.TargetProperty="(UIElement.Opacity)">
            <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0.8"/>
            <SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="1"/>
           </DoubleAnimationUsingKeyFrames>
           <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="contentPresenter" Storyboard.TargetProperty="(UIElement.Effect).(DropShadowEffect.Opacity)">
            <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
            <SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="0.8"/>
           </DoubleAnimationUsingKeyFrames>
          </Storyboard>
          <Storyboard x:Key="DropShadow_Opac80_Reverse">
           <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="contentPresenter" Storyboard.TargetProperty="(UIElement.Opacity)">
            <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
            <SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="0.8"/>
           </DoubleAnimationUsingKeyFrames>
           <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="contentPresenter" Storyboard.TargetProperty="(UIElement.Effect).(DropShadowEffect.Opacity)">
            <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0.8"/>
            <SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="0"/>
           </DoubleAnimationUsingKeyFrames>
          </Storyboard>
          <Storyboard x:Key="DropShadow_Clicked">
           <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="contentPresenter" Storyboard.TargetProperty="(UIElement.Effect).(DropShadowEffect.ShadowDepth)">
            <SplineDoubleKeyFrame KeyTime="00:00:00" Value="5"/>
            <SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="2"/>
           </DoubleAnimationUsingKeyFrames>
           <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="contentPresenter" Storyboard.TargetProperty="(UIElement.Effect).(DropShadowEffect.Direction)">
            <SplineDoubleKeyFrame KeyTime="00:00:00" Value="315"/>
           </DoubleAnimationUsingKeyFrames>
           <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="contentPresenter" Storyboard.TargetProperty="(UIElement.Effect).(DropShadowEffect.Opacity)">
            <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0.8"/>
            <SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="0.8"/>
           </DoubleAnimationUsingKeyFrames>
           <ThicknessAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="grid" Storyboard.TargetProperty="(FrameworkElement.Margin)">
            <SplineThicknessKeyFrame KeyTime="00:00:00" Value="2,2,0,0"/>
           </ThicknessAnimationUsingKeyFrames>
          </Storyboard>
          <Storyboard x:Key="DropShadow_Unclicked">
           <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="contentPresenter" Storyboard.TargetProperty="(UIElement.Effect).(DropShadowEffect.Opacity)">
            <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0.8"/>
           </DoubleAnimationUsingKeyFrames>
           <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="contentPresenter" Storyboard.TargetProperty="(UIElement.Effect).(DropShadowEffect.ShadowDepth)">
            <SplineDoubleKeyFrame KeyTime="00:00:00" Value="2"/>
            <SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="5"/>
           </DoubleAnimationUsingKeyFrames>
          </Storyboard>
         </ControlTemplate.Resources>
         <Grid x:Name="grid" Height="Auto" Margin="1" SnapsToDevicePixels="True">
          <ContentPresenter x:Name="contentPresenter" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" RecognizesAccessKey="True" Opacity="0.8" RenderTransformOrigin="0.5,0.5">
           <ContentPresenter.RenderTransform>
            <TransformGroup>
             <ScaleTransform/>
             <SkewTransform/>
             <RotateTransform/>
             <TranslateTransform/>
            </TransformGroup>
           </ContentPresenter.RenderTransform>
           <ContentPresenter.Effect>
            <DropShadowEffect Opacity="0"/>
           </ContentPresenter.Effect>
          </ContentPresenter>
         </Grid>
         <ControlTemplate.Triggers>
          <Trigger Property="IsKeyboardFocused" Value="true">
           <Trigger.ExitActions>
            <BeginStoryboard x:Name="DropShadow_Opac45_Reverse_BeginStoryboard" Storyboard="{StaticResource DropShadow_Opac45_Reverse}"/>
           </Trigger.ExitActions>
           <Trigger.EnterActions>
            <BeginStoryboard x:Name="DropShadow_Opac45_BeginStoryboard" Storyboard="{StaticResource DropShadow_Opac45}"/>
           </Trigger.EnterActions>
          </Trigger>
          <Trigger Property="IsEnabled" Value="false">
           <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
           <Setter Property="Opacity" TargetName="contentPresenter" Value="0.65"/>
          </Trigger>
          <Trigger Property="IsMouseOver" Value="True">
           <Trigger.ExitActions>
            <BeginStoryboard x:Name="DropShadow_Opac80_Reverse_BeginStoryboard" Storyboard="{StaticResource DropShadow_Opac80_Reverse}"/>
           </Trigger.ExitActions>
           <Trigger.EnterActions>
            <BeginStoryboard x:Name="DropShadow_Opac80_BeginStoryboard" Storyboard="{StaticResource DropShadow_Opac80}"/>
           </Trigger.EnterActions>
          </Trigger>
          <Trigger Property="IsPressed" Value="True">
           <Trigger.ExitActions>
            <RemoveStoryboard BeginStoryboardName="DropShadow_Clicked_BeginStoryboard"/>
            <BeginStoryboard x:Name="DropShadow_Unclicked_BeginStoryboard1" Storyboard="{StaticResource DropShadow_Unclicked}"/>
           </Trigger.ExitActions>
           <Trigger.EnterActions>
            <BeginStoryboard x:Name="DropShadow_Clicked_BeginStoryboard" Storyboard="{StaticResource DropShadow_Clicked}"/>
            <BeginStoryboard x:Name="DropShadow_Unclicked_BeginStoryboard" Storyboard="{StaticResource DropShadow_Unclicked}"/>
           </Trigger.EnterActions>
          </Trigger>
         </ControlTemplate.Triggers>
        </ControlTemplate>
       </Setter.Value>
      </Setter>
     </Style>
    </ResourceDictionary>
A: 

I tried your style on 3 systems, but they are working perfectly well. Check if the system which is causing the problem has SP1 of .net 3.5 installed.

Yogesh
Windows 7 Ultimate, x64. I've also installed SP1 of VS2008. The laptop that can run it well is running 7RC, with .Net SP1 as well...
dawmail333
Really can't figure it out then. But it is a good looking style though.
Yogesh