0

I have LayoutDocumentPane in my xaml named MainWindowPane. I am programmtically adding Tabs in the Pane using the below code.

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

Now Tabs are successfully added in the window , but when I click on any other tab , my app crashes and when I see the stack trace , it says it crashed on onModelChanged() Function.

Please help me out regarding this.

After lot of debugging found a solution for my question..

There was a threading issue as the layout inside my tabs was intitalized using a background worker, so it was not completely done while i was switching.

So now waited for the background worker to complete and then added the new Tab.

Rohit Jindal
  • 679
  • 1
  • 10
  • 21
  • 1
    Do you expect us to guess what your problem is? How can anyone determine what is wrong from that single line of code? You need to provide us with all the *relevant* information (not all the information). – Sheridan Sep 25 '14 at 09:12

1 Answers1

0

Try using this as a guide to what's not working with your code. I think you might be using the LayoutDocumentPane family instead of 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>

KVarmark
  • 226
  • 3
  • 4