wpf TabControl, possible to organize each tab in a different class?
Basically on my mainWindow Class it's getting crowded. My main question would be how to add the events on another class ?
So I tried adding a tabControl ... and wondering if each tabs control can be in a开发者_如何学编程 separate xaml and/or class.
an example would be much appreciated ;P Thanks
<Window ....... xmlns:uControl="clr-namespace:YOURPROJECT" >
<TabItem>
<uControl:UserControl1/>
</TabItem>
Two links that should help:
- C# Corner: UserControl in WPF
- stackoverflow
..and for your next problem: call-a-parent-method-from-UserControl
Each TabItem has a content property that can be set to whatever you want. The easiest way to seperate this out, is to put each section into a UserControl, and then just set your TabItems to those controls.
<TabControl>
<TabItem>
<my:UserControl1 />
</TabItem>
<TabItem>
<my:UserControl2 />
</TabItem>
</TabControl>
Where "my" has been mapped to some namespace in your solution that contains your UserControls.
精彩评论