我正在使用以下代码在我的 ScrollView 中显示很多按钮
foreach (RingModel ring in app.rings)
{
Button btn = new Button();
btn.BorderThickness = new Thickness(0, 0, 0, 0);
Image img = new Image();
img.Width = 100;
img.Height = 100;
img.Margin = new Thickness(5, 0, 0, 0);
Uri myUri = new Uri(ring.ringThumbNailImagePath, UriKind.Absolute);
BitmapImage bmi = new BitmapImage();
bmi.CreateOptions = BitmapCreateOptions.None;
bmi.UriSource = myUri;
img.Source = bmi;
btn.Content = img;
btn.Tag = i;
btn.Click += Ring_Click;
scrollStackPanel.Children.Add(btn);
i++;
}
但是这些按钮在点击时显示为蓝色背景。我想让它透明。我怎样才能让它成为可能。
请您参考如下方法:
在你共享的App.xaml下<Application.Resources>
写这个
<SolidColorBrush x:Key="ButtonDisabledBackgroundThemeBrush" Color="Ur color"/>
<SolidColorBrush x:Key="ButtonPressedBackgroundThemeBrush" Color="Ur Color" />
更多 http://msdn.microsoft.com/en-us/library/windows/apps/xaml/jj709909.aspx
