我正在使用F#代码中的AvalonEdit C#库并完成代码。一切似乎都按预期工作,显示代码完成窗口,正确弹出各个行的工具提示,将选定的单词插入到文档中。唯一的问题是完成窗口中的所有行都是空白的,就好像它们什么都没有。
单步执行Visual Studion 2013中的代码并不完全可用,因为它对完成窗口的行为有意想不到的影响,这与不使用断点时不同。
以下是从AvalonEdit帮助中获取并重写为F#的MyCompletionData:
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
答案 0 :(得分:0)
这可以按照这里描述的方式解决: 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