Hello
You should make a Command, like you mentioned.
You can access the Command in many ways, like this for one example:
<Hyperlink Command="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}, Path=DataContext.RemoveExpanderCommand, Mode=OneWay}" CommandParameter="{Binding Path=.}">
<Run Text="Delete group" />
</Hyperlink>
This example will fint the first Window ancestor. Change it to "UserControl" if you have a UserControl, or to the control name if you have a TemplatedControl.
Note : The are lots of ways to retrieve the command.
You can also use :
Command="{Binding RelativeSource={RelativeSource Mode=TemplatedParent} (...)
to access the "ItemsControl" directly.
You can also use :
Command="{Binding ElementName=MyElementName (...)
to access a specific control by the x:Name property.
I added "CommandParameter" with Path=. to send the current item to the Command, because the "ItemsControl" does not support "SelectedItem".
Then I remove the item from the list.
private void doRemoveExpander(MyClass param)
{
this.Items.Remove(param);
}
"Items" is a ObservableCollection<Myclass> which holds the items to view in the list. It is given in the "ItemsSource" for the ItemsControl.
Hope that helped a little :-)