Click here to Skip to main content
15,888,286 members
Please Sign up or sign in to vote.
2.33/5 (3 votes)
Guys,

I want to ask something about tab control in c#.
I've been doing this for couple of days and don't find it.

The tab item you can find it on xaml solution but you can't find it C# (code behind)like...

this is from xaml how am i to convert it to c#?(as a code behind?)
XML
<TabControl TabStripPlacement="Top" Margin="0, 0, 0, 10">
  <TabItem Name="tabIitemContent" Header="TabItem with Buttons">
    <StackPanel>
      <Button Content="_OK"/>
      <Button Content="_Cancel"/>
    </StackPanel>
  </TabItem>

  <TabItem Name="backgroundcolor" Header="Background">
    <TabItem.Content>Background property information goes here.</TabItem.Content>
  </TabItem>

  <TabItem Name="foregroundcolor" Header="Foreground">
    <TabItem.Content>Foreground property information goes here.</TabItem.Content>
  </TabItem>

  <TabItem Name="bordercolor" Header="BorderColor">
    <TabItem.Content>Border color property information goes here.</TabItem.Content>
  </TabItem>
</TabControl>
Posted
Updated 20-Apr-11 21:54pm
v4
Comments
Prerak Patel 21-Apr-11 0:55am    
Question is not clear.
Dalek Dave 21-Apr-11 3:54am    
Edited for Grammar and Readabilty.
phongsuk wangdu 21-Apr-11 4:06am    
thanks dalek..i will improve later on.

This Question makes no sense at all!
If this code behind, there is no "convert": code behind is used with XAML, not instead of it.

Perhaps, you really need C# equivalent of XAML. In this way, you would though out this XAML and code it all manually in C#. You need to start with some container, create a TabControl, add to a container. Look at the TabControl class, add everything in code. In principle, you can start with main window and go without any XAML at all. And no code behind at all.

Sorry, I think you have a little chance that somebody will be interested to do this boring work for you. You don't even conducted what you really want.

Maybe you have to make a big step back (I cannot tell exactly how much back) in your learning and find out how to do more elementary things.

—SA
 
Share this answer
 
Comments
Prerak Patel 21-Apr-11 0:58am    
Have a 5. I really couldn't understand the question itself.
Sergey Alexandrovich Kryukov 21-Apr-11 1:02am    
Thank you very much, Prerak.
--SA
phongsuk wangdu 21-Apr-11 3:04am    
i'm just asking..hey if u wanna just help me,but dont critise people.i know i really need much more learning gimme some break.
Tarun.K.S 21-Apr-11 3:19am    
Hey you are that character in the movie 3 Idiots!
Sergey Alexandrovich Kryukov 21-Apr-11 3:25am    
Why?!
--SA
I tried myself and this is how it will look like :

C#
TabControl tc = new TabControl();
TabItem item1 = new TabItem();
item1.Name = "tabIitemContent";
item1.Header = "Tab Item with Buttons";
StackPanel panel = new StackPanel();
Button btnOk = new Button();
btnOk.Content = "_OK";
panel.Children.Add(btnOk);
Button btnCancel = new Button();
btnOk.Content = "_Cancel";
item1.Content = panel;
tc.Items.Add(item1);

TabItem item2 = new TabIten();
item2.Name = "backgroundcolor";
item2.Header = "background";
item2.Content = "Background property information goes here.";
tc.Items.Add(item2);


I assume now you have got the idea how it works.
Good luck!
 
Share this answer
 
v2
Comments
phongsuk wangdu 21-Apr-11 3:33am    
thanks tarun K.S..THIS IS HOW COMMUNITY WORKS,SUPPORT EACH OTHER SAKryukov!!
Tarun.K.S 21-Apr-11 3:36am    
You're welcome. Do vote and accept the answer(s) which helped you.
Sergey Alexandrovich Kryukov 21-Apr-11 3:44am    
Why you address it to me? :-)
--SA
GlobX 26-Apr-11 18:39pm    
"THIS IS HOW COMMUNITY WORKS,SUPPORT EACH OTHER SAKryukov!!"

Hahaha! So, you're not so amazing after all, SA ;-)
Sergey Alexandrovich Kryukov 26-Apr-11 19:23pm    
Really? Do I have to be... after all? :-)
Or, who do you address to.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900