I want to remove the button background color when it is pressed and like to have transparent background since I am using image as a background.
Able to remove the border while mouse hover by the following code:
btn.BorderThickness = new Thickness(0,0,0,0);
btn.Padding = new Thickness(0, 0, 0, 0);
and by setting:
btn.Background = new Windows.UI.Xaml.Media.SolidColorBrush(Windows.UI.Colors.Transparent);
However I'm unable to remove the background while clicking on it, it is showing a gray colored background.
Any suggestions would be much appreciated.
No matter what you set, the default template will (should) override your value due to the Pressed
state of the CommonStates
VisualStateGroup
.
<VisualState x:Name="Pressed">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="RootGrid"
Storyboard.TargetProperty="Background">
<!-- This will cause the gray background color of the button -->
<DiscreteObjectKeyFrame
KeyTime="0"
Value="{ThemeResource SystemControlBackgroundBaseMediumLowBrush}" />
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
Instead of setting the color - as well as the border, how you're doing it right now - from code behind, you should create your own template for the buttons, setting the Background
to the desired value, e.g. Transparent
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With