我正在开发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属性吗? 你能否给我提供任何可以解决上述问题的代码或链接? 如果我做错了什么,请指导我。
I am developing window phone 7 application. I am new to the silverlight. In my application I need a dynamic combobox. So I am using the following code
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);In the above code I am unaware of how to set the right hand side of the following statement
CurrenciesCombobox.Foreground = ;Can you please tell me how to set the Foreground property of the combobx ? Can you please provide me any code or link through which I can resolve the above issue ? If I am doing anything wrong then please guide me.
最满意答案
要将其设置为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*/ });第二种方法提供了更多的灵活性
还有其他类型的笔刷: Brushes in Silverlight 。
另外,在使用Windows Phone 7 ,您应该考虑使用主题颜色。 看看可用的主题资源 。
To set it to White, use following code:
CurrenciesCombobox.Foreground = new SolidColorBrush(Colors.White);which is same as following:
CurrenciesCombobox.Foreground = new SolidColorBrush(new Color() { A = 255 /*Opacity*/, R = 255 /*Red*/, G = 255 /*Green*/, B = 255 /*Blue*/ });Second approach here provides more flexibility.
There are other types of Brushes as well: Brushes in Silverlight.
Also, while working with Windows Phone 7, you should consider using theme colors. Take a look at available theme resources.
更多推荐
发布评论