سؤال

I need to handle the text selection changed event in the Vspackage , i did a ton of google search and did not find any clue on how to do that , it seems very reasonable and should be very easy to do , not only is the documentation very bad , but none of microsoft samples on this topic show how to handle events . I would appreciate if any one has done this before and can provide me with the code .

Thanks

هل كانت مفيدة؟

المحلول

This is quick answer and should get you going.

[Export(typeof(IWpfTextViewCreationListener))]
[ContentType("text")]
internal sealed class SelectionCreatio : IWpfTextViewCreationListener
{
    public void TextViewCreated(IWpfTextView textView)
    {
        textView.Selection.SelectionChanged += (sender, args) =>
        {
            // do your stuff.
        }

    }
}

Mark your VSPackage as a MEF component and you're good to go.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top