【发布时间】:2014-08-10 18:56:51
【问题描述】:
最初我的 MainWindow(.xaml) 有一个堆栈面板和一个框架。堆栈面板中有三个导航按钮,框架具有三个页面之一(基于用户单击的导航按钮)。但是,似乎由于我不是在做一个网络应用程序,所以使用 Frame(和 Pages?)并不是正确的方法。所以我将堆栈面板和框架更改为单个选项卡控件(选项卡是之前的三个按钮)。我还将页面更改为用户控件。
但是,我在不使用框架的情况下将页面(现在的用户控件)放入 tabitem 的内容中时遇到了麻烦。我正在尝试在 MainWindow xaml 中完成所有这些操作。
我的 MainWindow.xaml:
<Window x:Class="ConstructedLanguageOrganizerTool.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" mc:Ignorable="d" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" Height="454" Width="573">
<Grid>
<TabControl HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Name="tabControl1">
<TabItem Header="Basics" Name="basicsTab">
//What can I use here instead of Frame?
</TabItem>
<TabItem Header="Words" Name="wordsTab">
<Grid>
<Frame Source="WordsPage.xaml"/>
</Grid>
</TabItem>
...
</TabControl>
</Grid>
</Window>
我是不是走错了路?我想我应该使用某种数据绑定,也许吧?虽然,我对数据绑定的了解越多,我对此也越感到困惑。
编辑:这是我的 BasicsPage.xaml
<UserControl x:Class="ConstructedLanguageOrganizerTool.BasicsPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d" x:Name="basicsPage" Height="349" Width="334">
<Grid>
// Grid Row and Column defs here
//Number of textboxs and textblocks here.
</Grid>
</UserControl>
【问题讨论】: