locked
VSIX : How do I change IOutliningRegionTag collapsed form format RRS feed

  • Question

  • How do I change the IOutliningRegionTag collapsed region format. I think that I would like to access and change the UIElement of the adornment that is the collapsed form of the outlining region. In the most simple case, I would like to specify a MarkerFormatDefinition and have the IOutliningRegionTag use that to render the collapsed form and possibly the collapsed hint form.

    Regards,

    Daniel  

    Tuesday, March 1, 2011 5:21 AM

All replies

  • Hello Daniel,

     

    Thank you for your question.

     

    I am currently looking into this issue and will give you an update as soon as possible.

     

    Thank you for your understanding and support.

     

    Best Regards,

    Ziwei Chen

     

    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg @ microsoft.com


    Ziwei Chen [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, March 2, 2011 6:04 AM
  • Hello Victor,

    I yield in GetTags with

     

     

    yield new TagSpan<IOutliningRegionTag>( node.SnapshotSpan, new OutliningRegionTag( true, false, collapsedText, tooltipText ) );

    Now, if collapsedText is a simple string, then everything works fine but no ability to format the text.

    If collapsedText is some form of control, such as TextBox or Run then the control is presented with the formatted content but when I try to scroll down my text and the control needs to get destroyed I get an exception because the control does not seem to be properly destroyed.

    If collapsed text is something like FormattedText then the text is not even presented and what I see in the editor is the class name in a box.

    Daniel


    Daniel
    Wednesday, March 2, 2011 3:54 PM
  • Victor,

    An additionnal note. If instead of creating the OutliningRegionTag with collapsedText as a string, I create it as a Rectangle for example, I then see the rectangle in the editor view but if I then scroll down the view I get a:

    A first chance exception of type 'System.InvalidOperationException' occurred in PresentationFramework.dll
    
    Additional information: Specified element is already the logical child of another element. Disconnect it first.

    I get the same message if I create the collapsedText as a control such as TextBlox.

    Daniel 


    Daniel
    Thursday, March 3, 2011 5:08 AM
  • Hi Daniel,

    Supplying a visual element such as TextBlock or Rectangle for the 'collapsedText' and 'tooltipText' works fine on an Outlining tagger that I created some time ago. I think you might be returning the same visual for each TagSpan the method yields, which would explain the exception. Can you verify if this works without exceptions?

    yield return new TagSpan<IOutliningRegionTag>(node.SnapshotSpan, new OutliningRegionTag(true, false, new TextBlock() { Text = collapsedText }, new TextBlock() { Text = tooltipText }));

    • Proposed as answer by billb08 - MSFT Tuesday, April 19, 2011 9:23 PM
    Thursday, March 3, 2011 9:21 PM
  • Hi Bert.

    Regretfully, your code still gives me the same System.InvalidOperationException at the same point in the program when it is trying to execute the framework's

    > PresentationFramework.dll!System.Windows.FrameworkElement.ChangeLogicalParent(System.Windows.DependencyObject newParent) + 0x12a bytes 

    When I open my file in the editor, the first screen comes up properly, with the TextBox controls appearing as the collapsed text properly, but when I scroll down oof the screen , I get the exception.

    The foreach loop in GetTags is straightforward:

        foreach ( var node in parseNodes )

        {

            if ( node.SnapshotSpan.Start >= overallSpan.End )

                break;

            if ( node.SnapshotSpan.End <= node.SnapshotSpan.Start || node.SnapshotSpan.End <= overallSpan.Start )

                continue;

            // this gives exception

            // yield return new TagSpan<IOutliningRegionTag>( node.SnapshotSpan, new OutliningRegionTag( true, false

                                , new TextBlock() { Text = "Whatever" }, new TextBlock() { Text = "Yes, whatever" } ) );

            // this gives no exception

            yield return new TagSpan<IOutliningRegionTag>( node.SnapshotSpan, new OutliningRegionTag( true, false

                                , "Whatever", "Yes, whatever" ) );

        }

     


    Daniel
    Friday, March 4, 2011 3:38 PM