none
How to attach a TabItem to a TabControl using C# code instead of XAML RRS feed

  • Question

  • I'm experimenting with WPF applications.  Using the designer I created a TabControl with two TabItems that are set up in XAML.  Then I wanted to see about creating a third TabItem in C# code and attaching it to the TabControl using code instead of XAML.  Here is what I have so far.

    However, at this point, I can't find any method or property in TabControl that lets me append the new TabItem.  Is there a way to do this in C# code?

    Monday, May 25, 2020 10:48 PM

All replies

  • Hi MesPia,

    Thank you for posting here.

    According to your description, your issue is more related to WPF. Therefore, it will be more appropriate to ask your question in WPF forum.

    The CLR Forum discuss and ask questions about .NET Framework Base Classes (BCL) such as Collections, I/O, Regigistry, Globalization, Reflection. Also discuss all the other Microsoft libraries that are built on or extend the .NET Framework.

    Thank you for your understanding.

    Best Regards,

    Xingyu Zhao


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, May 26, 2020 1:24 AM
  • I had selected Windows Presentation Foundation (WPF) when I asked the question, so I assumed the question would be addressed to the WPF Forum.  Don't know how I got here.
    Thursday, May 28, 2020 10:09 PM
  • When I click on "Ask a Question" I don't see WPF listed in either the Forum Categories or the Forum list.  How do I get a question directed to the WPF forum?  Also, can I get a reply to my email address: nickajp@comcast.net

    Thursday, May 28, 2020 10:13 PM
  • Hi MesPia,

    The original WPF forum has moved to the new WPF forum: Microsoft Q&A(Preview).

    Microsoft Q&A(Preview) allows us to add new functionality and enables easier access to all the technical resources most useful to you, like Microsoft Docs and Microsoft Learn.

    Hope you can get help in the new WPF forum.

    Best Regards,

    Xingyu Zhao


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, May 29, 2020 6:05 AM