E Shindler
E Shindler

Reputation: 457

Create a TabControl programmatically in WPF(C#)

I am a newbie to C# and WPF in particular and I'm wondering how to create a TabControl programatically(not via xaml). I have the following code:

private void Button_Click_3(object sender, RoutedEventArgs e)
   {
   TabControl c = new TabControl() 
  }

But the TabControl is not created when the button is clicked. Could someone please give me a basic example on how to create a TabControl programatically. This may also help me understand how WPF works(I am more used to Swing Java). Many thanks.

Upvotes: 0

Views: 468

Answers (1)

SLaks
SLaks

Reputation: 887225

You need to add the TabControl to some part of your window.

Specifically, you should add it to the Children collection of some kind of panel.

Upvotes: 1

Related Questions