Show the Collapsed Text

SyntaxEditor for WPF Forum

Posted 10 years ago by cowcow
Version: 10.1.0522
Avatar
Hi,

In the "Collaspsed Regions - Advanced", you have the example of collapsing selected text. However, I cannot find any example demonstrate how to show the collapsd text. What I am trying to do is to allow user to click the "..." adornment to expand/show the collapsed text.

Could you please give me a example?

Thanks,
Cow

Comments (2)

Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
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.


Actipro Software Support

Posted 10 years ago by cowcow
Avatar
Instead of using Border, I use a Button. I then put the code in the Click event of the Button.

I work perfect.

Thanks.
The latest build of this product (v2019.1 build 0683) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.