C# 如何动态设置combox的前台属性?
我正在开发WindowsPhone7应用程序。我对silverlight是新手。在我的应用程序中,我需要一个动态组合框。因此,我使用以下代码C# 如何动态设置combox的前台属性?,c#,silverlight,combobox,windows-phone-7,C#,Silverlight,Combobox,Windows Phone 7,我正在开发WindowsPhone7应用程序。我对silverlight是新手。在我的应用程序中,我需要一个动态组合框。因此,我使用以下代码 ComboBox CurrenciesCombobox = null; CurrenciesCombobox = new ComboBox(); CurrenciesCombobox.Name = "CurrencyCombobox"; CurrenciesCombobox.SetValue(
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的前台属性吗?
你能提供我任何代码或链接,通过它我可以解决上述问题吗?如果我做错了什么,请指导我。要将其设置为
白色
,请使用以下代码:
CurrenciesCombobox.Foreground = new SolidColorBrush(Colors.White);
如下所示:
CurrenciesCombobox.Foreground = new SolidColorBrush(new Color()
{
A = 255 /*Opacity*/,
R = 255 /*Red*/,
G = 255 /*Green*/,
B = 255 /*Blue*/
});
这里的第二种方法提供了更大的灵活性
还有其他类型的笔刷:
此外,在使用<代码> Windows Phone 7 < /C>时,应考虑使用主题颜色。看看可用的。试试下面这些
CurrenciesCombobox.Foreground = (Brush)Application.Current.Resources["PhoneAccentBrush"];
此处详细介绍了更多选项
或
CurrenciesCombobox.Foreground = new SolidColorBrush(Colors.Red);