C# WPF-ReactiveUI InvokeCommand不工作
我正在尝试学习ReactiveUI,所以我正在制作示例应用程序,但我在C# WPF-ReactiveUI InvokeCommand不工作,c#,wpf,reactiveui,C#,Wpf,Reactiveui,我正在尝试学习ReactiveUI,所以我正在制作示例应用程序,但我在InvokeCommand方面遇到了问题。基本上每次更改SearchPhrase属性时,都应该调用我的showsearchphrase命令 以下是我的看法: <StackPanel Grid.Column="1" Grid.Row="1" Orientation="Horizontal" VerticalAlignment="Center" > <TextBox Width="100" H
InvokeCommand
方面遇到了问题。基本上每次更改SearchPhrase
属性时,都应该调用我的showsearchphrase命令
以下是我的看法:
<StackPanel Grid.Column="1" Grid.Row="1" Orientation="Horizontal"
VerticalAlignment="Center" >
<TextBox Width="100" Height="20"
Text="{Binding Path=SearchPhrase, UpdateSourceTrigger=PropertyChanged}" />
</StackPanel>
这是我的问题:
该命令需要一个单元
:
this.WhenAnyValue(x => x.SearchPhrase)
.Where(x => !string.IsNullOrWhiteSpace(x))
.Select(_ => System.Reactive.Unit.Default) //<--
.InvokeCommand(ShowSearchPhraseCommand);
this.whenyValue(x=>x.SearchPhrase)
.Where(x=>!string.IsNullOrWhiteSpace(x))
.Select(=>System.Reactive.Unit.Default)//
this.WhenAnyValue(x => x.SearchPhrase)
.Where(x => !string.IsNullOrWhiteSpace(x))
.Select(_ => System.Reactive.Unit.Default) //<--
.InvokeCommand(ShowSearchPhraseCommand);
public ReactiveCommand<string, System.Reactive.Unit> ShowSearchPhraseCommand { get; private set; }
...
ShowSearchPhraseCommand = ReactiveCommand.Create<string>(ShowSearchPhraseCommandHandler);