Have you tried this?
searchEditPanel.Children.Remove(_EditFileControle);
Another suggestion:
Maybe this helps: http://sachabarber.net/?p=162
if it is not: add a property to your UserControl:
public UserControl ParentControl {get;set;}
Now change your code:
private void button1_Click(object sender, RoutedEventArgs e)
{
whichSelected = listViewFiles.SelectedIndex;
_EditFileControle.ParentControl = this;
searchEditPanel.Children.Add(_EditFileControle);
}
Now you can do it:
if (this.ParentControl != null)
this.ParentControl.Children.Remove(this);
source
share