How to Change Button Foreground and Background When Pressed and Released
Currently I have a need to place a 'back' button within my application.
This is not to replace the hardware back button, but to go back to a
previous state of an item if the user does not wish to continue with his
or her change of an item. Currently I have the following xaml for my
MainPage, which binds an image as well as places the 'back' button on the
view as well.
MainPage.xaml
<Grid x:Name="MainPageGrid" Margin="{Binding}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width=".2*"/>
<ColumnDefinition Width=".2*"/>
<ColumnDefinition Width=".2*"/>
<ColumnDefinition Width=".2*"/>
<ColumnDefinition Width=".2*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height=".2*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Image x:Name="currentPhoto" Grid.ColumnSpan="5"
Grid.RowSpan="2"
Source="{Binding Source}" Margin="12,0,12,12"
HorizontalAlignment="Center"
VerticalAlignment="Center"
toolkit:TiltEffect.IsTiltEnabled="True"/>
<Button x:Name="photoRefreshButton" Grid.Row="0"
Grid.Column="5"
BorderBrush="Transparent"
Click="photoRefreshButton_Click"
toolkit:TiltEffect.IsTiltEnabled="True">
<Image Source="Assets/Buttons/back.png"/>
</Button>
</Grid>
I would like to be able to toggle the foreground and background when the
button is pressed and released, but I am unsure of how to change the
button template style for this. I would like to use the following setup:
Not Pressed
Foreground = #FF1BA1E2 (ARGB: 255, 27, 161, 226)
background = transparent
Pressed
Foreground = Current theme foreground brush
background = transparent
No comments:
Post a Comment