TabControl在调整窗口大小时调整大小,如何停止自动调整大小

时间:2014-07-01 20:45:50

标签: wpf resize tabcontrol

当我调整窗口大小时,我的标签内容会自动调整大小。但是当我调整窗口大小时,我不希望内容调整大小。因为我的TabItem.Content被包装。如何在TabControl中停止此文本换行?

<Window x:Class="Editor.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"  Title="Pattern Editor" 
    xmlns:local="clr-namespace:Editor"           
    Height="629.875" Width="910">
    <DockPanel Name="mainPanel">            
        <ScrollViewer DockPanel.Dock="Top" VerticalScrollBarVisibility="Auto">
            <DockPanel>
                 <Label Name="Formatter" Width="Auto" Height="Auto" FontFamily="Lucida Console" Background="LightGray"/>
                 <TabControl DockPanel.Dock="Top" x:Name="EditorTabcontrol" FontFamily="Lucida Console" HorizontalAlignment="Stretch">                   
                </TabControl>
            </DockPanel>
        </ScrollViewer>
    </DockPanel>
</Window>

XAML背后的部分代码:

RichTextBox mcRTB = new RichTextBox();
rtbList.Add(mcRTB);
mcRTB.SelectionChanged += mcRTB_SelectionChanged;
TabItem tab = new TabItem();
tabItemList.Add(tab);

try
{
    Paragraph paragraph = new Paragraph();
        paragraph.Inlines.Add(System.IO.File.ReadAllText(filePath));

        FileInfo fi = new FileInfo(filePath);
        FlowDocument document = new FlowDocument(paragraph);

        mcRTB.Document = document;
}
mcRTB.TextChanged += new System.Windows.Controls.TextChangedEventHandler(SegFileDataContentChanged);                       
tab.Header = ExtractFileName(filePath);
tab.Content = mcRTB;
tab.Focus();
tab.DataContext = segFile;
ProgressBar.DataContext = segFile;  

1 个答案:

答案 0 :(得分:1)

你不能

RichTextBox

  

文本始终包含在RichTextBox中。