UWP 选项卡视图没有响应

问题描述 投票:0回答:2

我有一个带有选项卡视图的页面。每个选项卡内都有另一个页面。每当我尝试与选项卡交互时,都没有任何效果。我尝试以 SettingsPage 作为内容与其进行交互,并且成功了。

主页 - 包含选项卡

TabbedMainPage - 包含工作区

SettigsPage - 包含设置

主页:

    private void TabView_AddTabButtonClick(TabView sender, object args)
    {
        sender.TabItems.Add(CreateNewTab());
    }

    public TabViewItem OpenSettingsTab()
    {
        TabViewItem newItem = new TabViewItem();
        newItem.Header = "Settings";
        newItem.IconSource = new Microsoft.UI.Xaml.Controls.SymbolIconSource() { Symbol = Symbol.Setting };
        Frame frame = new Frame();
        frame.Navigate(typeof(SettingsPage));
        newItem.Content = frame;
        TabbedView.UpdateLayout();
        return newItem;
    }

    public void CreateSettingsTab()
    {
        TabbedView.TabItems.Add(OpenSettingsTab());
        TabbedView.UpdateLayout();
        TabbedView.SelectedIndex = TabbedView.TabItems.Count - 1;
    }

    public TabViewItem CreateNewTab()
    {
        TabViewItem newItem = new TabViewItem();
        newItem.Header = "New Tab";
        newItem.IconSource = new Microsoft.UI.Xaml.Controls.SymbolIconSource() { Symbol = Symbol.Document };
        Frame frame = new Frame();
        frame.Navigate(typeof(TabbedMainPage));
        newItem.Content = frame;
        TabbedView.UpdateLayout();
        return newItem;
    }

    private void TabbedView_Loaded(object sender, RoutedEventArgs e)
    {
        var S = sender as TabView;
        if (S.TabItems.Count == 0)
        {
            S.TabItems.Add(CreateNewTab());
        }
        TabbedView.UpdateLayout();
    }

TabbedMainPage 具有以下组件:ColorPicker、DropDownButton、MenuBar、Border、Button、CheckBox、ComboBox、Flyout、Grid、Image、MenuFlyout、Pivot、PivotItem、StackPanel、TextBlock、TextBox、Flyout、Popup、RichEditBox、ScrollViewer、Slider、ToggleButton和工具提示。

我认为这可能是由于组件过载造成的,但我不确定。我的代码中也有这些:

    MediaElement ME;

    SpeechSynthesizer Synth;

    public StorageFile TXTFile;

    public IRandomAccessStream RAS;

    private readonly PrintHelperOptions PP = new PrintHelperOptions();

    var LS = ApplicationData.Current.LocalSettings;

    var TB = ApplicationView.GetForCurrentView().TitleBar;

    var CTB = CoreApplication.GetCurrentView().TitleBar;
c# uwp tabview
2个回答
1
投票

我设法通过从工具栏中删除枢轴来修复该错误。它干扰了选项卡功能,因此我将所有项目合并在一起。


0
投票

oi 14 岁,如果你不给我和龙免费的 ivirius 文本编辑器 plus,我会将你的脸发布到网上

© www.soinside.com 2019 - 2024. All rights reserved.