如何使用C#代码构建DataTemplate?
我正在尝试为winform互操作构建下拉列表,并且正在代码中创建下拉列表。但是,在基于指定的DataTemplate绑定数据时遇到问题。 我想念什么? drpCreditCardNumberWpf = new ComboBox(); DataTemplate cardLayout = new DataTemplate {DataType = typeof (CreditCardPayment)}; StackPanel sp = new StackPanel { Orientation = System.Windows.Controls.Orientation.Vertical }; TextBlock cardHolder = new TextBlock {ToolTip = "Card Holder Name"}; cardHolder.SetBinding(TextBlock.TextProperty, "BillToName"); sp.Children.Add(cardHolder); TextBlock cardNumber = new TextBlock {ToolTip = "Credit Card Number"}; cardNumber.SetBinding(TextBlock.TextProperty, "SafeNumber"); …