//NuGet包
<ItemGroup>
<PackageReference Include="ReactiveUI" Version="16.2.6" />
<PackageReference Include="ReactiveUI.Events.Winforms" Version="15.1.1" />
<PackageReference Include="ReactiveUI.Fody" Version="16.2.6" />
<PackageReference Include="ReactiveUI.WinForms" Version="16.2.6" />
</ItemGroup>
//文本框Text变化时候执行操作
this.WhenAnyValue(s => s.textBox1.Text)
.Subscribe((t) => Debug.WriteLine(t));
//全局变量
public ReactiveCommand<MouseEventArgs, System.Reactive.Unit> ClickCmd;
public Form1()
{
InitializeComponent();
//事件 传参 窗体其他控件操作!
ClickCmd = ReactiveCommand.Create<MouseEventArgs>(a =>
{
this.textBox1.Focus();
this.textBox1.Text = "123456789";
this.button1.Focus();
});
this.button1.Events().Click.InvokeCommand(this, x => x.ClickCmd);
}