Hello,
The adornment created by the adornment manager, in this case a Border, would need to have a Click event handler. Since Border doesn't have a Click event, you will need to wrap the Border in another element that does support the Click event.
In your new Click event handler in the adornment manager, you will need to get the tagger:
SyntaxEditor editor = View.SyntaxEditor;
CollapsedRegionTagger tagger = null;
if (editor.Document.Properties.TryGetValue(typeof(CollapsedRegionTagger), out tagger)) {
// Do stuff with tagger
}
Dim editor As SyntaxEditor = View.SyntaxEditor
Dim tagger As CollapsedRegionTagger = Nothing
If editor.Document.Properties.TryGetValue(GetType(CollapsedRegionTagger), tagger) Then
' Do stuff with tagger
End If
Once you have the tagger, you need to acquire the adornment, where sender is the element that sent the Click event:
IAdornment adornment = AdornmentLayer.FindAdornment(sender as UIElement);
Dim adornment As IAdornment = AdornmentLayer.FindAdornment(TryCast(sender, UIElement))
Get the CollapsedRegionTag from the adornment and remove it from the tagger:
CollapsedRegionTag tag = adornment.Tag as CollapsedRegionTag;
if(tag != null) {
TagVersionRange<ICollapsedRegionTag> tagVersionRange = tagger[tag];
if (tagVersionRange != null)
tagger.Remove(tagVersionRange);
}
Dim tag As CollapsedRegionTag = TryCast(adornment.Tag, CollapsedRegionTag)
If tag IsNot Nothing Then
Dim tagVersionRange As TagVersionRange(Of ICollapsedRegionTag) = tagger(tag)
If tagVersionRange IsNot Nothing Then
tagger.Remove(tagVersionRange)
End If
End If
Please let us know if you have further questions.