将不同页面(包含在 xaml 或外部页面中)作为选项卡内容的选项卡控件

本文关键字:选项 控件 外部 包含 xaml | 更新日期: 2023-09-27 17:56:36

您好,感谢您的阅读,也许会提供帮助:-)

我的代码下面带有语句。

我有我的MainWindow.xaml,我有我的CheckBoxTabControl.

<CheckBox Grid.Column="8" Grid.Row="2" Name="checkBoxCommon" HorizontalAlignment="Right" VerticalAlignment="Center" IsChecked="{Binding IsCheckedCommon}"/>
    <Grid Grid.Column="0" Grid.ColumnSpan="10" Grid.Row="4">
    <TabControl ItemsSource="{Binding Path=DpConfigCol>
    <TabControl.ItemTemplate>
        <DataTemplate>
            <ContentControl Content="{Binding Path=DpConfigName}>
                <ContentControl.Resources>
                    <DataTemplate DataType="types:ConfigCommon">
                    </DataTemplate>
                    <DataTemplate DataType="types:ConfigAdress">
                    </DataTemplate>
                </ContentControl.Resources>
            </ContentControl>
        </DataTemplate>
    </TabControl.ItemTemplate>
    <TabControl.ContentTemplate>
        <DataTemplate>
            <ContentControl>
                <ContentControl.Resources>
                    <DataTemplate DataType="types:ConfigCommon">
                        <TextBlock Text="hallo" Width="150"/>
                    </DataTemplate>
                    <DataTemplate DataType="types:ConfigAdress">
                    </DataTemplate>
                </ContentControl.Resources>
            </ContentControl>
        </DataTemplate>
    </TabControl.ContentTemplate>
</TabControl>

如果我勾选我的复选框,它将向我的ObservableCollection()添加一个新模型。

private bool _isCheckedCommon;
public bool IsCheckedCommon
{
    get { return _isCheckedCommon; }
    set
    {
        _isCheckedCommon = value;
        if (_isCheckedCommon == true)
        {
            DpConfigCol.Add(new ConfigCommon("Common"));
        }
        else
        {
            foreach (object item in DpConfigCol)
            {
                if (item.GetType().ToString()==typeof(ConfigCommon).FullName.ToString())
                {
                    DpConfigCol.Remove(item);
                    break;
                }
            }
        }
        return;
    }
}

我用这个叫做DpConfigCol的收藏绑定了我的tabcontrol

现在我的问题:

如何使属性(来自我的模型:ConfigCommon)在我的tabcontrol.ContentTemplate中可见?如果有多个复选框包含更多模型?有没有办法在该Tabcontrol.contentTemplate为多个模型实现多个模板?

将不同页面(包含在 xaml 或外部页面中)作为选项卡内容的选项卡控件

TLDR;(仅阅读标题)

我还必须开发一个使用过一次选项卡的应用程序。您可以在标签页中使用<Frame>,并将其Content设置为您想要的任何XAML page