Sud*_*dha 6 xamarin xamarin.forms uwp
我想在按下时删除按钮背景颜色,并且喜欢具有透明背景,因为我使用图像作为背景.
鼠标悬停时能够通过以下代码删除边框:
btn.BorderThickness = new Thickness(0,0,0,0);
btn.Padding = new Thickness(0, 0, 0, 0);
Run Code Online (Sandbox Code Playgroud)
并通过设置:
btn.Background = new Windows.UI.Xaml.Media.SolidColorBrush(Windows.UI.Colors.Transparent);
Run Code Online (Sandbox Code Playgroud)
但是我点击它时无法删除背景,它显示的是灰色背景.
任何建议将不胜感激.
无论你设置什么,默认模板都会(应该)覆盖你的值,因为它的Pressed状态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>
Run Code Online (Sandbox Code Playgroud)
而不是设置颜色 - 以及边框,你现在如何做 - 从后面的代码,你应该为按钮创建自己的模板,设置Background为所需的值,例如Transparent.
| 归档时间: |
|
| 查看次数: |
4004 次 |
| 最近记录: |