关于我们

质量为本、客户为根、勇于拼搏、务实创新

< 返回新闻公共列表

WPF:极简ComboBox的内容模板

发布时间:2020-03-24 00:00:00

一、设置内容模板如下

 二、前端调用(xaml)        aaabbb三、代码调用(cs)            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;四、效果图如下" _ue_custom_node_="true">

/template/Home/Zkeys/PC/Static