This project has moved and is read-only. For the latest updates, please go here.

MultiLineTextEditor: Load/Unload = Exception

Aug 21, 2011 at 3:00 PM

XAML
<Button Grid.Row="0" Click="AddButton_Click" Content="Add"/>
<Button Grid.Row="1" Click="RemoveButton_Click" Content="Remove" />
<ContentControl Grid.Row="2" x:Name="contentControl" />

Code Behind
private void AddButton_Click(object sender, RoutedEventArgs e)
{
   contentControl.Content = new MultiLineTextEditor();
}
private void RemoveButton_Click(object sender, RoutedEventArgs e)
{
   contentControl.Content = null;
}

Action: Add, Remove, Add = Exception: "Specified element is already the logical child of another element. Disconnect it first."

Demo source code: http://dalexs.homedns.org/Files/MultiLineTextEditorBug.zip

What is wrong? How to workaround?

Aug 21, 2011 at 4:27 PM

Problem in image that use as content in MultiLineTextEditor. 

Workaround (for example):
public class CustomMultiLineTextEditor : MultiLineTextEditor
{
      protected override void OnInitialized(EventArgs e)
      {
         this.Content = null;  
         base.OnInitialized(e);
      }
}

Aug 22, 2011 at 3:51 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Aug 22, 2011 at 3:57 PM

This has been resolved.  You can get the fix in the latest source code.