c# – 如何动态设置combox的Foreground属性?
发布时间:2020-12-15 23:56:53 所属栏目:百科 来源:网络整理
导读:我正在开发 windows phone 7应用程序.我是银光的新手.在我的应用程序中,我需要一个动态组合框.所以我使用以下代码 ComboBox CurrenciesCombobox = null;CurrenciesCombobox = new ComboBox(); CurrenciesCombobox.Name = "CurrencyCombobox"; CurrenciesComb
我正在开发
windows 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属性吗? 解决方法
要将其设置为白色,请使用以下代码:
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时,您应该考虑使用主题颜色.看看theme resources. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |