[英]How to define a custom routedeventargs in F#?
I have a need to define a custom routedeventarg in F# (to be used by both C# code and F# code).我需要在 F# 中定义自定义 routedeventarg(供 C# 代码和 F# 代码使用)。
In C#, I have defined the following在C#中,我定义了以下内容
public class NewTranscriptEventArgs : RoutedEventArgs
{
private readonly string appendtext;
public string AppendText
{
get { return appendtext; }
}
public NewTranscriptEventArgs(RoutedEvent routedEvent, string appendtext) : base(routedEvent)
{
this.appendtext = appendtext;
}
}
I have no good idea on how this would be translated into F#.我不知道如何将其转换为 F#。
Ultimately, the custom NewTranscriptEventArgs will be sent to the F# back-end by:最终,自定义 NewTranscriptEventArgs 将通过以下方式发送到 F# 后端:
<i:EventTrigger EventName="NewTranscript">
<i:InvokeCommandAction PassEventArgsToCommand="True" Command="{Binding NewTranscript}" />
</i:EventTrigger>
Thanks for any help.谢谢你的帮助。
Ugh: How simple:呃:多么简单:
type NewTranscriptEventArgs(r:RoutedEvent, appendText: string ) =
inherit RoutedEventArgs(r)
member this.AppendText = appendText
I haven't tried to run the code, but this is a literal translation to F#:我没有尝试运行代码,但这是对 F# 的直译:
type NewTranscriptEventArgs(routedEvent, appendText : string) =
inherit RoutedEventArgs(routedEvent)
member _.AppendText = appendText
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.