0

プロトタイプで動作していたため、これが機能しない理由について少し混乱しています。唯一の大きな違いは、デフォルトのものではなくカスタム TabItem と UserControl を使用していることです。タブウィンドウの中央に表示されるユーザーコントロールを取得しようとしていますが、左に配置されているようです。

使用したいユーザーコントロールをこのメソッドに渡すと、それをフォーマットしてタブコントロールに貼り付けます。以前に行ったテスト ソリューションでは、スクロールの水平方向と垂直方向の配置をストレッチに設定すると、これが修正されましたが、この場合は機能しません。これをオーバーライドする他の設定または何か他の場所はありますか?

public void CreateNewTab(UserControlGeneric new_user_control, string tab_header)
    {
        //TabItem tab = new TabItem();
        TabItemIndexed tab = new TabItemIndexed();
        //The scrollviewer is created/setup to make sure the usercontrol gets scroll bars if the window if ever made smaller than the usercontrol
        ScrollViewer scroll = new ScrollViewer();

        //How you programatically set a scrollviewer's height and width to be "Auto"
        scroll.Height = Double.NaN;
        scroll.Width = Double.NaN;

        scroll.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
        scroll.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
        scroll.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
        scroll.VerticalAlignment = System.Windows.VerticalAlignment.Stretch;

        scroll.Content = new_user_control;
        tab.Content = scroll;
        tab.Header = tab_header;

        //If there aren't any tabs, then hide the "No Workspaces Open" notice (Since we're adding a tab)
        if (!tabControl_main.HasItems) label_no_workspaces_open.Visibility = System.Windows.Visibility.Hidden;

        tabControl_main.Items.Add(tab);
        tabControl_main.SelectedItem = tab;

    }
4

0 に答える 0