如何卸下按钮';按下时的背景色-xamarin形成UWP
我想在按下按钮时删除按钮的背景色,并希望有透明背景,因为我使用图像作为背景。如何卸下按钮';按下时的背景色-xamarin形成UWP,xamarin,xamarin.forms,uwp,Xamarin,Xamarin.forms,Uwp,我想在按下按钮时删除按钮的背景色,并希望有透明背景,因为我使用图像作为背景。 通过以下代码,可以在鼠标悬停时删除边框: btn.BorderThickness = new Thickness(0,0,0,0); btn.Padding = new Thickness(0, 0, 0, 0); 通过设置: btn.Background = new Windows.UI.Xaml.Media.SolidColorBrush(Windows.UI.Colors.Transparent); 但是,我
通过以下代码,可以在鼠标悬停时删除边框:
btn.BorderThickness = new Thickness(0,0,0,0);
btn.Padding = new Thickness(0, 0, 0, 0);
通过设置:
btn.Background = new Windows.UI.Xaml.Media.SolidColorBrush(Windows.UI.Colors.Transparent);
但是,我无法在单击背景时删除它,它显示的是灰色背景。任何建议都将不胜感激。无论您设置了什么,由于按下了
CommonState的状态,将(应该)覆盖您的值
<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>
与其从代码隐藏中设置颜色以及边框,还不如为按钮创建自己的模板,将背景设置为所需的值,例如透明
是否尝试过targetButton.BackgroundColor=color.Transparency已找到它,移除了故事板本身。谢谢though@Sudha您可以批准答案,或关闭问题:)@Herdo是否有办法通过样式等删除所有按钮的背景?@Shimmy当然,只需设置按钮的默认样式。