[WPF 学习] 8.极简ComboBox的内容模板
2021-03-13 12:32
标签:scrollbar ystemd string nav mamicode width nes direct path 一、设置内容模板如下 二、前端调用(xaml) 三、代码调用(cs) 四、效果图如下 [WPF 学习] 8.极简ComboBox的内容模板 标签:scrollbar ystemd string nav mamicode width nes direct path 原文地址:https://www.cnblogs.com/catzhou/p/12546197.html
ComboBox cb = new ComboBox() { Background=Brushes.Red,BorderBrush=Brushes.Blue,BorderThickness=new Thickness(2)};
cb.Items.Add( new TextBox { Text = "aaa" ,Foreground=Brushes.White} );
cb.Items.Add(new TextBox { Text = "bbb", Foreground = Brushes.Green });
cb.SelectedIndex = 0;
cb.Template = Resources["ComboBoxTemplate1"] as ControlTemplate;