Diasble button animation or effects xamarin-forms

2019-09-11 08:34发布

问题:

I have a touch screen to start page, and would just want to navigate to the next page when tapped - no animations/color changing effects on hover, clicked/pressed. But there's a gray opaque box when clicked... Anyone know how to override it?

P.S. I know there are more ways to do this but I decided to create the whole page as a button and reduced the opacity to almost transparent.

回答1:

The easiest way to achieve this would be to remove the Button's template:

<Button Template="{x:Null}">
    ... your content
</Button>

Alternatively you can create a Button style, with just ContentPresenter in its template:

<Style x:Key="InvisibleButtonStyle" TargetType="Button">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="Button">
                <ContentPresenter />
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

And you can reuse this style on multiple places.