2014-09-25 117 views
0

我在名为MainWindowPane的xaml中有LayoutDocumentPane。我使用下面的代码在程序中编程添加选项卡。无法在LayoutDocumentPane中的标签之间切换

MyViewer viewer = new MyViewer(); 
LayoutDocument tempTabItem = new LayoutDocument(); 
tempTabItem.Closed += onTabItemClosed; 
tempTabItem.Content = viewer; 
MainWindowPane.Children.Add(tempTabItem); 
MainDockManager.ActiveContent = 0; 

现在,制表符在窗口成功添加,但是当我点击任何其他选项卡上,我的应用程序崩溃,当我看到堆栈跟踪,它说,它坠毁,机上onModelChanged()函数。

请帮我解决这个问题。

很多调试发现我的问题解决后..

有一个线程问题,因为我的标签里面的布局使用后台工人被intitalized,所以它,而我是开关没有完全完成。

所以现在等待后台工作人员完成,然后添加新的选项卡。

+1

你希望我们去猜测你的问题是什么?任何人都可以从单行代码中确定哪些是错误的?您需要向我们提供所有*相关*信息(并非所有信息)。 – Sheridan 2014-09-25 09:12:43

回答

0

请尝试使用它作为不适用于您的代码的指南。我想你可能会使用LayoutDocumentPane系列而不是LayoutAnchorablePane

<Window x:Class="WpfApplication1.MainWindow" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:xcad="http://schemas.xceed.com/wpf/xaml/avalondock" 
    xmlns:s="clr-namespace:System;assembly=mscorlib"> 
<xcad:DockingManager> 
    <xcad:LayoutRoot> 
     <xcad:LayoutPanel Orientation="Horizontal"> 
      <xcad:LayoutAnchorablePaneGroup DockWidth="125"> 
       <xcad:LayoutAnchorablePane> 
        <xcad:LayoutAnchorable ContentId="alarms" Title="Alarms"> 
         <ListBox Margin="-1,0,1,0"> 
          <s:String>Alarm 1</s:String> 
          <s:String>Alarm 2</s:String> 
          <s:String>Alarm 3</s:String> 
         </ListBox> 
        </xcad:LayoutAnchorable> 
        <xcad:LayoutAnchorable ContentId="journal" Title="Journal" > 
         <RichTextBox> 
          <FlowDocument> 
           <Paragraph FontSize="14" FontFamily="Segoe"> 
            This is the content of the Journal Pane. 
            <LineBreak/> 
            A 
            <Bold>RichTextBox</Bold> has been added here 
           </Paragraph> 
          </FlowDocument> 
         </RichTextBox> 
        </xcad:LayoutAnchorable> 
       </xcad:LayoutAnchorablePane> 
      </xcad:LayoutAnchorablePaneGroup> 
     </xcad:LayoutPanel> 
    </xcad:LayoutRoot> 
</xcad:DockingManager>