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 677023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:59:36+00:00 2026-05-14T00:59:36+00:00

Is there any good tutorial for creating WPF controls entirely at runtime? Thanks

  • 0

Is there any good tutorial for creating WPF controls entirely at runtime?

Thanks

  • 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. Editorial Team
    Editorial Team
    2026-05-14T00:59:36+00:00Added an answer on May 14, 2026 at 12:59 am

    There is no such a tutorial I know of, partially because that is quite straightforward if you’ve got already your XAML definition for the control.

    The correspondence between XAML code and corresponding C# code is simple.

    Example:

    <Button Height="80" Width="150">Test</Button>
    

    gets into

    Button button = new Button() { Height = 80, Width = 150, Content = "Test" };
    parentControl.Add(button);
    

    The things you should know:

    1. Content model: where does the content (the code between the opening and closing tags) go? It can be either property Content (as in Button‘s case), or a set of child items (as in case of Grid).
    2. In XAML sometimes special value converters are implicitly applied; in C# code you must do it yourself. Example:

      <Button Margin="1, 2"/>
      

      turns into

      Button button = new Button() { Margin = new Thickness(1, 2, 1, 2) };
      
    3. Each UI element can have only one parent element. That is, you cannot add the same element to two different parents as a child.

    4. Bindings are defined in a quite peculiar way:

      <Label MaxWidth={Binding ActualWidth, Source={Binding ElementName=Container}}>
      

      gets into

      Label label = new Label();
      label.SetBinding(
          Label.MaxWidthProperty,
          new Binding("ActualWidth") { Source = Container }
      );
      

      (it’s better to reference the Container by actual reference than by name).

    5. The syntax for attached properties is again not straightforward:

      <Label Grid.Column="1"/>
      

      turns into

      Label label = new Label();
      Grid.SetColumn(label, 1);
      

    Please note that for each of the constructs/attributes you can look up in MSDN the exact way to express it in both XAML and C#, usually directly at the article describing the concept you are looking for.

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

Sidebar

Ask A Question

Stats

  • Questions 384k
  • Answers 384k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer First, if you have a crash, you have a backtrace.… May 14, 2026 at 11:01 pm
  • Editorial Team
    Editorial Team added an answer Check This Out var data = from d in db.tb… May 14, 2026 at 11:01 pm
  • Editorial Team
    Editorial Team added an answer The closest thing is arguments.callee, which actually returns the function… May 14, 2026 at 11:01 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.