我正在开发 window phone 7 应用程序。我是银光的新手。在我的应用程序中,我需要一个动态组合框。所以我使用下面的代码
ComboBox CurrenciesCombobox = null;
CurrenciesCombobox = new ComboBox();
CurrenciesCombobox.Name = "CurrencyCombobox";
CurrenciesCombobox.SetValue(Canvas.TopProperty, 10.00);
CurrenciesCombobox.SetValue(Canvas.LeftProperty, 10.00);
CurrenciesCombobox.Margin = new Thickness(235, 395, 139, 180);
//CurrenciesCombobox.Foreground = ;
CurrenciesCombobox.ItemsSource = Currencies;
CurrenciesCombobox.SelectionChanged += new SelectionChangedEventHandler(CurrenciesCombobox_SelectionChanged);
ContentPanel.Children.Add(CurrenciesCombobox);
在上面的代码中,我不知道如何设置下面语句的右侧
CurrenciesCombobox.Foreground = ;
你能告诉我如何设置 combobx 的 Foreground 属性吗? 您能否提供我可以解决上述问题的任何代码或链接?如果我做错了什么,请指导我。
最佳答案
要将其设置为White
,请使用以下代码:
CurrenciesCombobox.Foreground = new SolidColorBrush(Colors.White);
与下面相同:
CurrenciesCombobox.Foreground = new SolidColorBrush(new Color()
{
A = 255 /*Opacity*/,
R = 255 /*Red*/,
G = 255 /*Green*/,
B = 255 /*Blue*/
});
这里的第二种方法提供了更大的灵 active 。
还有其他类型的笔刷:Brushes in Silverlight
.
此外,在使用 Windows Phone 7
时,您应该考虑使用主题颜色。看看有空theme resources .
关于c# - 如何动态设置组合框的前景属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4508575/