开发者

WPF search windows - like tabPages in tab control

开发者 https://www.devze.com 2022-12-14 08:37 出处:网络
I have idea to implement my wpf windows like TabPages in tab control. It is possible to do that dynamically in c# code.

I have idea to implement my wpf windows like TabPages in tab control. It is possible to do that dynamically in c# code.

In Example i have Menu in main window. Some Menu items calls search type windows. Is it possible to do such a thing in C# code (SomeMenuItem_Click): this code adds new tab in tabControl of main window.

If there are no search windows called -there is no tab's shown, if there are many search windows called - there are many tab's.

So how do I code this?

And whats the technique with the windows? I suppose that my search type windows must be implemented like some UserControls. I think its no a good idea to implement that like simple wpf windows. I have tried to do that by using Marlon grech "Blend like UIs using DOCKY", find at:

http://marlongrech.wordpress.com/2008/01/29/create-blend-like-uis-using-docky/

But I failed, dont find the way h开发者_如何学Goow to add controlls in code dynamically, not in xaml.

I would appreciate code examples to illustrate how to achieve this.


Is it possible to do such a thing in C# code (SomeMenuItem_Click): this code adds new tab in tabControl of main window.

Yes. The basic pattern is:

TabItem newItem = new TabItem();
tabControl.Items.Add(newItem);

You'll obviously need to set the relevant properties of your tab item (such as the Header and Style) but that should get you started.

You'll then need to create any controls you want to show and add them to the tab item itself (or more correctly - a container within the tab item).

0

精彩评论

暂无评论...
验证码 换一张
取 消