MindRoasterMir
MindRoasterMir

Reputation: 370

System.InvalidCastException: 'Unable to cast object of type 'System.Windows.Documents.FlowDocument' to type 'System.Windows.Media.Visual'.'

<ad:DockingManager>
        <ad:LayoutRoot>
            <ad:LayoutPanel Orientation="Horizontal">
                <ad:LayoutPanel>

                    <ad:LayoutDocumentPaneGroup>
                        <ad:LayoutDocumentPane >
                            <ad:LayoutDocument>
                                <RichTextBox>Here is Error!!!</RichTextBox>
                            </ad:LayoutDocument>
                        </ad:LayoutDocumentPane>
                    </ad:LayoutDocumentPaneGroup>
                </ad:LayoutPanel>
                <ad:LayoutPanel>
                    <ad:LayoutAnchorablePaneGroup>
                        <ad:LayoutAnchorablePane>
                            <ad:LayoutAnchorable>
                                <RichTextBox x:Name="achorRichText"></RichTextBox>
                                </ad:LayoutAnchorable>
                        </ad:LayoutAnchorablePane>
                    </ad:LayoutAnchorablePaneGroup>
                </ad:LayoutPanel>
                </ad:LayoutPanel>         
        </ad:LayoutRoot>
    </ad:DockingManager>

I am learning C# using Visual Studio. I am trying to use Xceed Avalondoc. I used a RichTextBox in a LayoutDocument tag. It give this error

System.InvalidCastException: 'Unable to cast object of type 'System.Windows.Documents.FlowDocument' to type 'System.Windows.Media.Visual'.'

when I click in the RichTextBox after program runs.

Can you help me remove this error. Thanks

Upvotes: 0

Views: 1360

Answers (1)

MindRoasterMir
MindRoasterMir

Reputation: 370

So long story short I found the reason and the solution to this strange problem.

Actually I was using the latest version of Xceed AvalonDock in my new project and It has a bug. I found an old version 2.0.0 of AvalonDock & it worked. I have following specifications in my Project.

  1. Visual Studio Enterprise 2019
  2. WPF Framework Project
  3. .Net Framework 4.7.2
  4. Avalon.Wpf.Toolkit version 1.9

Thanks

Upvotes: 1

Related Questions