Xamarin 如何将WhenyValue和TopProperty与F#一起使用?

Xamarin 如何将WhenyValue和TopProperty与F#一起使用?,xamarin,f#,reactiveui,c#-to-f#,Xamarin,F#,Reactiveui,C# To F#,我不熟悉F#和reactiveui,有人能帮我把下面的C#代码翻译成F吗# 这是我尝试过的,即使我不知道这是不是正确的方法 this.WhenAnyValue(toLinq <@ fun (vm:LoginViewModel) -> vm.Username @>, toLinq <@ fun (vm:LoginViewModel) -> vm.Password @>) .Where(fun (u, p) -> (not String.IsNull

我不熟悉F#和reactiveui,有人能帮我把下面的C#代码翻译成F吗#

这是我尝试过的,即使我不知道这是不是正确的方法

this.WhenAnyValue(toLinq <@ fun (vm:LoginViewModel) -> vm.Username @>, toLinq <@ fun (vm:LoginViewModel) -> vm.Password @>)
    .Where(fun (u, p) -> (not String.IsNullOrEmpty(u)) && (not String.IsNullOrEmpty(p)) && p.Length > 6)
    .Select(fun _ -> true)
    .ToProperty(this, (fun vm -> vm.IsValid), &_isValid) |> ignore
此.whenyValue(toLinq vm.Username@>和toLinq vm.Password@>)
.Where(fun(u,p)->(not String.IsNullOrEmpty(u))&&(not String.IsNullOrEmpty(p))&&p.Length>6)
.选择(乐趣->真实)
.ToProperty(这是,(fun vm->vm.IsValid),&(u IsValid)|>忽略
我得到一个错误:


错误:连续的参数应该用空格或元组分隔,涉及函数或方法应用程序的参数应该用括号括起来

not String.IsNullOrEmpty(u)
括号在F中不像在C中那样有特殊意义。在F#中,它们只是括号,不是调用方法的特殊语法。换句话说,上述表达式相当于:

not String.IsNullOrEmpty u
我认为现在的问题应该是显而易见的:这看起来像是在用两个参数调用
而不是
函数,而实际上你想做的是:

not (String.IsNullOrEmpty u)
或者这个:

not <| String.IsNullOrEmpty u

不是哪一行给出了错误?你能试着把它分成几个单独的语句来缩小范围吗?好吧,它不是同一个代码太棒了!谢谢
not <| String.IsNullOrEmpty u
let notEmpty = not << String.IsNullOrEmpty

// And then:
notEmpty u