Белые линии вместо слов в CompletionWindow (пространство имен CodeCompletion), когда AvalonEdit используется из F#

Я использую библиотеку C# AvalonEdit из кода F# и выполняю завершение кода. Вроде все работает как положено, показывается окно завершения кода, всплывающие подсказки на отдельных его строках всплывают корректно, выделенные слова вставляются в документ. Единственная проблема заключается в том, что все строки в окне завершения пусты, как будто в них ничего нет.

Пошаговое выполнение кода в Visual Studion 2013 здесь не совсем подходит, поскольку оно оказывает неожиданное влияние на поведение окна завершения, которое отличается от того, когда точки останова не используются.

Вот MyCompletionData, взятый из справки AvalonEdit и переписанный на F#:

module CompletionData

open ICSharpCode.AvalonEdit.CodeCompletion
open System
open System.Windows.Media.Imaging

/// Implements AvalonEdit ICompletionData interface to provide the entries in the
/// completion drop down.
type MyCompletionData (text:string) = 
    let _text = text

    interface ICompletionData with

        member this.Complete (textArea, completionSegment, insertionRequestEventArgs) =
            textArea.Document.Replace(completionSegment, ((this :> ICSharpCode.AvalonEdit.CodeCompletion.ICompletionData).Text: string));

        // Use this property if you want to show a fancy UIElement in the list.
        member this.Content
            with get () = (this :> ICSharpCode.AvalonEdit.CodeCompletion.ICompletionData).Text :> obj

         member this.Description
            with get () = ("Description for " + (this :> ICSharpCode.AvalonEdit.CodeCompletion.ICompletionData).Text ) :> obj

        member  this.Image
            with get () = null 

        member this.Priority
            with get () = 1.0

        member this.Text = _text

person veeco    schedule 25.01.2015    source источник
comment
Я не имею права размещать здесь фотографии. Некоторые изображения, связанные с проблемой, и полный код находятся здесь https://github.com/icsharpcode/AvalonEdit/issues/28 .   -  person veeco    schedule 05.02.2015


Ответы (1)


Это можно решить, как описано здесь: http://stackoverflow.com/questions/15476046/databinding-a-f-viewmodel< /а>

Самый прямой обходной путь — определить его как явное свойство (и реализация интерфейса может просто ссылаться на основное свойство

type MyCompletionData (text:string) = 
    let _text = text

    member this.Text = text

    member this.Complete (textArea:TextArea, completionSegment, insertionRequestEventArgs) =
            textArea.Document.Replace(completionSegment, ((this :> ICSharpCode..CodeCompletion.ICompletionData).Text: string));

    member this.Content = (this :> ICSharpCode..CodeCompletion.ICompletionData).Text :> obj

    member this.Description = ("Description for " + (this :> ICSharpCode..CodeCompletion.ICompletionData).Text ) :> obj

    member  this.Image = null

    member this.Priority = 1.0

    interface ICompletionData with

        member this.Complete (textArea, completionSegment, insertionRequestEventArgs) =
            this.Complete (textArea, completionSegment, insertionRequestEventArgs)

        // Use this property if you want to show a fancy UIElement in the list.
        member this.Content = this.Content

        member this.Description = this.Description

        member  this.Image = this.Image

        member this.Priority = this.Priority            

        member this.Text = this.Text 
person Goswin    schedule 17.08.2017