FSharp.ReactiveWpf
0.1.3
dotnet add package FSharp.ReactiveWpf --version 0.1.3
NuGet\Install-Package FSharp.ReactiveWpf -Version 0.1.3
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="FSharp.ReactiveWpf" Version="0.1.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="FSharp.ReactiveWpf" Version="0.1.3" />
<PackageReference Include="FSharp.ReactiveWpf" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add FSharp.ReactiveWpf --version 0.1.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: FSharp.ReactiveWpf, 0.1.3"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package FSharp.ReactiveWpf@0.1.3
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=FSharp.ReactiveWpf&version=0.1.3
#tool nuget:?package=FSharp.ReactiveWpf&version=0.1.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
FSharp.ReactiveWpf
一个用于 F# 和 WPF 的轻量级响应式绑定工具集。库通过 System.Reactive 提供各种控件与 IObservable / ISubject 的绑定辅助函数,便于在函数式风格下构建 WPF 界面。
快速说明:文档中的 API 以模块名.函数名 形式给出,示例使用 System.Reactive.Subjects 和 System.Reactive.Disposables 来管理数据流与生命周期。
快速开始
示例演示如何创建数据源并将其绑定到控件:
open System.Reactive.Subjects
open System.Reactive.Disposables
open System.Windows
open System.Windows.Controls
open FSharp.ReactiveWpf
let disposable = new CompositeDisposable()
// 数值输入框(浮点)
let numberSubject = new BehaviorSubject<float>(0.0)
let numberTextBox = NumberBox.createFloat disposable numberSubject
// 文本绑定到已有 TextBox
let textSubject = new BehaviorSubject<string>("hello")
let tb = TextBox()
TextBox.bindFocus disposable tb textValue
TextBox.bindLostFocus disposable tb textValue
// 复选框
let boolSubject = new BehaviorSubject<bool>(false)
let check = CheckBox.create disposable boolSubject "启用"
// 单选按钮组(按索引)
let radioIndex = new BehaviorSubject<int>(-1)
let r1, r2, r3 = RadioButton(), RadioButton(), RadioButton()
r1.Content <- "A"; r2.Content <- "B"; r3.Content <- "C"
RadioButton.bindingRadioButtonGroup disposable radioIndex [| r1; r2; r3 |]
// Run 文本元素
let run = Run.create disposable textSubject
// 播放列表 (MediaPlayer)
let mediaPlayer = new MediaPlayer()
let playlistSubject = new BehaviorSubject<seq<string>>(Seq.empty)
let playback = MediaPlayer.createPlaylistObservable mediaPlayer (playlistSubject :> IObservable<_>)
let sub = playback.Subscribe() // 触发播放副作用
// 将控件加入窗口等
主要 API 参考(按模块)
注意:下列签名为库中可见函数的简化描述,实际使用时以代码编辑器的提示为准。
NumberBox
- createFloat : CompositeDisposable → TextBox → ISubject<float> → TextBox
- createSingle : CompositeDisposable → TextBox → ISubject<float32> → TextBox
- createInt64 : CompositeDisposable → TextBox → ISubject<int64> → TextBox
- createInt : CompositeDisposable → TextBox → ISubject<int> → TextBox
- bindFocus / bindLostFocus : 绑定焦点事件,更新状态
TextBox
- bindFocus : CompositeDisposable → TextBox → IObservable<string> → unit
- bindLostFocus : CompositeDisposable → TextBox → ISubject<string> → unit
- create : CompositeDisposable → TextBox → ISubject<string> → unit
ComboBox
- bindIndex : CompositeDisposable → ComboBox → ISubject<int> → unit
- bindItem : CompositeDisposable → ComboBox → ISubject<'t> → unit
- indexCreate : CompositeDisposable → ComboBox → seq<'t> → ISubject<int> → ComboBox
- itemCreate : CompositeDisposable → ComboBox → seq<'t> → ISubject<'t> → ComboBox
ToggleButton / CheckBox
- ToggleButton.bind : CompositeDisposable → ToggleButton → ISubject<bool> → unit
- ToggleButton.create : CompositeDisposable → ToggleButton → ISubject<bool>
- CheckBox.bind : CompositeDisposable → CheckBox → ISubject<bool> → unit
- CheckBox.create : CompositeDisposable → CheckBox → ISubject<bool> → obj → CheckBox
RadioButton
- bindingRadioButton : CompositeDisposable → ISubject<bool> → RadioButton → unit
- bindingRadioButtonGroup : CompositeDisposable → ISubject<int> → RadioButton[] → unit
- bindingRadioButtonGroupUsingContent : CompositeDisposable → ISubject<string> → RadioButton[] → unit
Run
- bind : CompositeDisposable → Run → IObservable<string> → unit
- create : CompositeDisposable → Run → IObservable<string> → Run
TextBlock
- bind : CompositeDisposable → TextBlock → IObservable<string> → unit
- create : CompositeDisposable → TextBlock → IObservable<string> → TextBlock
MediaPlayer
- playMany : MediaPlayer → string[] → IDisposable
- createPlaylistObservable : MediaPlayer → IObservable<#seq<string>> → IObservable<unit>
- createPlaylistObservable2 : (string → unit) → MediaPlayer → IObservable<#seq<string>> → IObservable<unit>
设计要点
- 基于 System.Reactive:所有数据流使用 IObservable / ISubject,以便函数式组合与订阅管理。
- 关注点分离:UI 控件创建/绑定逻辑与业务数据分离,便于测试。
贡献
欢迎提交 Issue 与 Pull Request。请确保代码风格与现有文件一致并附带简单说明。
许可证
GPLv3
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0-windows7.0 is compatible. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0-windows7.0
- FSharp.Core (>= 10.1.302)
- FSharp.Idioms (>= 1.5.16)
- MahApps.Metro (>= 2.4.11)
- System.Reactive (>= 7.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.1.3 | 46 | 8/1/2026 |
| 0.1.2 | 62 | 7/31/2026 |
| 0.1.1 | 78 | 7/30/2026 |
| 0.1.0 | 84 | 7/30/2026 |
| 0.0.22 | 87 | 7/29/2026 |
| 0.0.21 | 85 | 7/29/2026 |
| 0.0.20 | 93 | 7/20/2026 |
| 0.0.19 | 92 | 7/18/2026 |
| 0.0.18 | 91 | 7/18/2026 |
| 0.0.17 | 87 | 7/17/2026 |
| 0.0.16 | 82 | 7/15/2026 |
| 0.0.15 | 98 | 7/14/2026 |
| 0.0.14 | 96 | 7/11/2026 |
| 0.0.13 | 112 | 6/29/2026 |
| 0.0.12 | 104 | 6/28/2026 |
| 0.0.11 | 136 | 1/26/2026 |
| 0.0.10 | 131 | 1/19/2026 |
| 0.0.9 | 125 | 1/16/2026 |
| 0.0.8 | 178 | 12/6/2025 |
| 0.0.7 | 232 | 12/4/2025 |
Loading failed
Table