在主选项卡式窗口中添加 xaml 文件
我正在尝试创建一个带有选项卡式界面的应用程序。现在我有这样的界面
使用此代码
<Window x:Class="BMG.BackOffice.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="572" Width="776">
<TabControl>
<TabItem>
<TabItem.Header>
<TextBlock>
tab1
</TextBlock>
</TabItem.Header>
<Label>Test for tab1</Label>
</TabItem>
<TabItem>
<TabItem.Header>
<TextBlock>
tab2
</TextBlock>
</TabItem.Header>
</TabItem>
<TabItem>
<TabItem.Header>
<TextBlock>
tab3
</TextBlock>
</TabItem.Header>
</TabItem>
<TabItem>
<TabItem.Header>
<TextBlock>
tab4
</TextBlock>
</TabItem.Header>
</TabItem>
</TabControl>
我已经编写了其他窗口,我想知道是否可以“插入”这些窗口在选项卡中(选项卡的窗口)。因此要替换 通过窗口(.xaml 文件)
感谢您的回复
I'm trying to create a application with tabbed interface. For now I have this kind of interface
with this code
<Window x:Class="BMG.BackOffice.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="572" Width="776">
<TabControl>
<TabItem>
<TabItem.Header>
<TextBlock>
tab1
</TextBlock>
</TabItem.Header>
<Label>Test for tab1</Label>
</TabItem>
<TabItem>
<TabItem.Header>
<TextBlock>
tab2
</TextBlock>
</TabItem.Header>
</TabItem>
<TabItem>
<TabItem.Header>
<TextBlock>
tab3
</TextBlock>
</TabItem.Header>
</TabItem>
<TabItem>
<TabItem.Header>
<TextBlock>
tab4
</TextBlock>
</TabItem.Header>
</TabItem>
</TabControl>
I have already write other windows and I wonder if is it possible to "insert" these windows in the tabs (a window for a tab). So to replace <Label>Test for tab1</Label>
by a window (.xaml file)
Thanks for response
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
通常,您会将这些窗口控件转换为 UserControls,然后将它们嵌入到 TabItems 中。
我不知道您是否可以在另一个窗口中创建一个窗口,但请阅读 这个问题 Thomas Levesque 说一个 tabitem 中不能有另一个窗口。
Normally you would convert those window controls to UserControls and then embed those inside the TabItems.
I don't know if you can have a window inside another window but reading this question Thomas Levesque says that one can't have another window inside a tabitem.
您可以加载窗口并获取其
Content
属性,因为窗口本身不能是另一个控件的子级。我应该注意到,这非常混乱,最好的解决方案可能是将 Window 的 内容 转换为 UserControl,这样您就可以在 Window 和TabControl,我猜曾经可以称之为复合 UI 重构。
You could load the Window and get its
Content
property since a Window itself cannot be the child of another control.I should note that this is very messy, the best solution is probably to turn the content of the Window into a UserControl, that way you can use it in the Window and the TabControl, once could call that composite UI refactoring i guess.