C#代码后面的Tab控件 [英] Tab control in C# code behind
本文介绍了C#代码后面的Tab控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
伙计们,
我想问一下有关C#中的选项卡控件的问题.
我已经这样做了几天,却没有找到.
您可以在xaml解决方案上找到它的选项卡项目,但不能像C ...(后面的代码)那样找到它...
这来自xaml,我如何将其转换为c#?(作为背后的代码?)
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?)
<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>
推荐答案
这个问题根本没有道理!
如果后面有此代码,则不存在转换":后面的代码与XAML和一起使用,不代替它.
也许,您确实需要等效于XAML的C#.这样,您就可以使用此XAML并在C#中手动对其进行编码.您需要从某个容器开始,创建一个TabControl
,然后添加到一个容器中.查看TabControl
类,在代码中添加所有内容.原则上,您可以从主窗口开始,而根本不使用任何XAML.而且根本没有任何代码.
抱歉,我认为您很少有机会为您完成这项无聊的工作.您甚至都没有进行您真正想要的事情.
也许您必须在学习中大步退缩(我无法确切说出多少退缩),并找出如何做更多基本的事情.
—SA
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 aTabControl
, add to a container. Look at theTabControl
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
我尝试了一下,这是这样的:
I tried myself and this is how it will look like :
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!
这篇关于C#代码后面的Tab控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文