Skip to content

InvalidOperationException when using ContentControl inside DocumentDock #1102

Description

@jurihock

Steps to reproduce in the DockXamlSample example in this repository:

Modification in view ItemsSourceExample.axaml:

<StackPanel DataContext="{Binding Context}">
  <StackPanel x:DataType="local:MyDocumentModel">
    <!-- insert ContentControl pointing to MyButton -->
    <ContentControl Content="{Binding MyButton}"/>
    <!-- ... -->
  </StackPanel>
</StackPanel>

Modification in view model MyDocumentModel.cs:

public class MyDocumentModel : INotifyPropertyChanged
{
  // insert MyButton as instance of Button (or another control)
  public Button MyButton { get; } = new() { Content = "CLICK ME" };
}

Start DockXamlSample, open "ItemsSource Example", and rearrange docking tabs:

System.InvalidOperationException: 'The control XXX already has a visual parent ContentPresenter (Name = PART_ContentPresenter, Host = ContentControl) while trying to add it as a child of ContentPresenter (Name = PART_ContentPresenter, Host = ContentControl).'

Dock version v12.0.0.2. Was not an issue in previous Dock version 11.

See also:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions