c# - 如何动态设置组合框的前景属性?

标签 c# silverlight combobox windows-phone-7

我正在开发 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/

相关文章:

c# - 使用 WinDbg 和 SOS 调试挂起的 .net 应用程序、死锁或失控线程?

c# - 将不同的数字类型作为参数发送到方法时是否存在性能问题?

c# - 向 C# 命名空间添加描述

silverlight - 在 Silverlight 中使用安全关键构造函数子类化透明类型的安全规则

ExtJS:如何提交:组合框值和文本

c# - 获取角色的替代代码

silverlight - 使用 Google Web Toolkit (GWT) 时的主要缺点是什么

银光 + RIA : problem editing entity

c++ - winAPI 中的组合框样式编辑控件

c# - 如何更新 ComboBox