1

I have a very simple visual state manager for Button which animates the color of a border and zooms the image content of a button to the Pressed state. This works when pressed with the mouse, but when using a touch screen the Pressed state is only reached after the finger is smudged over the button (some dragging occurs over the face of the button).

I looked at all the CommonStates for Button, but there is no Touched state. Anything I'm overlooking?

<VisualStateManager.VisualStateGroups>
    <VisualStateGroup x:Name="CommonStates">
        <VisualStateGroup.Transitions>
            <VisualTransition GeneratedDuration="0:0:0.05" />
            <VisualTransition GeneratedDuration="0:0:0.1" To="Pressed" />
        </VisualStateGroup.Transitions>
        <VisualState x:Name="Normal" />
        <VisualState x:Name="Pressed">
            <Storyboard>
                <ColorAnimation Storyboard.TargetName="ButtonBorder" Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color)" To="#A9CC3D"/>
                <DoubleAnimation Storyboard.TargetName="GrayBorder" Storyboard.TargetProperty="(Border.Background).(ImageBrush.RelativeTransform).(ScaleTransform.ScaleX)" To="1.1"/>
                <DoubleAnimation Storyboard.TargetName="GrayBorder" Storyboard.TargetProperty="(Border.Background).(ImageBrush.RelativeTransform).(ScaleTransform.ScaleY)" To="1.1"/>
            </Storyboard>
        </VisualState>
    </VisualStateGroup>
</VisualStateManager.VisualStateGroups>

The odd thing is that before we had it working using ControlTemplate.Triggers.

Wouter
  • 2,170
  • 1
  • 28
  • 58

1 Answers1

0

The problem is that by default Windows maps touch hold to right click. Check the following Stackoverflow discussion on how to disable this behavior on a control/window level.

Disable a right click (press and hold) in WPF application.

Community
  • 1
  • 1
Wouter
  • 2,170
  • 1
  • 28
  • 58