Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 62513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T18:29:16+00:00 2026-05-10T18:29:16+00:00

I am trying to build a dropdown list for a winform interop, and I

  • 0

I am trying to build a dropdown list for a winform interop, and I am creating the dropdown in code. However, I have a problem getting the data to bind based on the DataTemplate I specify.

What am I missing?

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'); sp.Children.Add(cardNumber);  TextBlock notes = new TextBlock {ToolTip = 'Notes'}; notes.SetBinding(TextBlock.TextProperty, 'Notes'); sp.Children.Add(notes);  cardLayout.Resources.Add(sp, null);  drpCreditCardNumberWpf.ItemTemplate = cardLayout; 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T18:29:16+00:00Added an answer on May 10, 2026 at 6:29 pm

    Assuming that you’ve already set up the ItemsSource etc for drpCreditCardNumberWpf…

    //create the data template DataTemplate cardLayout = new DataTemplate(); cardLayout.DataType = typeof(CreditCardPayment);  //set up the stack panel FrameworkElementFactory spFactory = new FrameworkElementFactory(typeof(StackPanel)); spFactory.Name = 'myComboFactory'; spFactory.SetValue(StackPanel.OrientationProperty, Orientation.Horizontal);  //set up the card holder textblock FrameworkElementFactory cardHolder = new FrameworkElementFactory(typeof(TextBlock)); cardHolder.SetBinding(TextBlock.TextProperty, new Binding('BillToName')); cardHolder.SetValue(TextBlock.ToolTipProperty, 'Card Holder Name'); spFactory.AppendChild(cardHolder);  //set up the card number textblock FrameworkElementFactory cardNumber = new FrameworkElementFactory(typeof(TextBlock)); cardNumber.SetBinding(TextBlock.TextProperty, new Binding('SafeNumber')); cardNumber.SetValue(TextBlock.ToolTipProperty, 'Credit Card Number'); spFactory.AppendChild(cardNumber);  //set up the notes textblock FrameworkElementFactory notes = new FrameworkElementFactory(typeof(TextBlock)); notes.SetBinding(TextBlock.TextProperty, new Binding('Notes')); notes.SetValue(TextBlock.ToolTipProperty, 'Notes'); spFactory.AppendChild(notes);  //set the visual tree of the data template cardLayout.VisualTree = spFactory;  //set the item template to be our shiny new data template drpCreditCardNumberWpf.ItemTemplate = cardLayout; 

    You can use the same way I have set the ToolTip on the TextBlocks to set other properties such as margins.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to build an AutoComplete DropDown List that will work on a Mobile
Very simple problem...but weird results. Im just trying to fill a drop down list
I'm trying to get values from numerous dropdown lists and build a where statement
I am trying to build a simple drop down list for my MVC application.
I am trying to build an Infopath form which populates fields with data back
Im trying to build my dropdown menu using the plugin Chosen for Multiple Select
I have a search form built in ASP.NET that has a dropdown list which
I am trying to build a country suggestion list with flag included in the
In TFS2010 I am having trouble creating Build Definitions . I have created a
I am trying to build an HtmlHelper extension in ASP.NET MVC RC2. This code

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.