Skip to content

Commit 05fca0a

Browse files
authored
Update Readme for IViewFor (#18)
1 parent 44b3366 commit 05fca0a

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

README.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@ These Source Generators were designed to work in full with ReactiveUI V19.5.31 a
77
- [Reactive]
88
- [ObservableAsProperty]
99
- [ReactiveCommand]
10+
- [ReactiveCommand(CanExecute = nameof(IObservableBoolName))] with CanExecute
11+
- [ReactiveCommand][property: AttribueToAddToCommand] with Attribute passthrough
12+
- [IViewFor(nameof(ViewModelName))]
1013

1114
Versions older than V19.5.31 to this:
1215
- [Reactive] fully supported,
1316
- [ObservableAsProperty] fully supported,
14-
- [ReactiveCommand] all supported except Cancellation Token asnyc methods.
17+
- [ReactiveCommand] all options supported except Cancellation Token asnyc methods.
1518

1619
# Historical ways
1720
## Read-write properties
@@ -251,6 +254,34 @@ public partial class MyReactiveClass
251254
}
252255
```
253256

257+
## Usage IViewFor `[IViewFor(nameof(ViewModelName))]`
258+
259+
### IViewFor usage
260+
261+
IVIewFor is used to link a View to a ViewModel, this is used to link the ViewModel to the View in a way that ReactiveUI can use it to bind the ViewModel to the View.
262+
The ViewModel is passed as a string to the IViewFor Attribute.
263+
The class must inherit from a UI Control from any of the following platforms and namespaces:
264+
- Maui (Microsoft.Maui)
265+
- WinUI (Microsoft.UI.Xaml)
266+
- WPF (System.Windows or System.Windows.Controls)
267+
- WinForms (System.Windows.Forms)
268+
- Avalonia (Avalonia)
269+
- Uno (Windows.UI.Xaml).
270+
271+
```csharp
272+
using ReactiveUI.SourceGenerators;
273+
274+
[IViewFor(MyReactiveClass)]
275+
public partial class MyReactiveControl : UserControl
276+
{
277+
public MyReactiveControl()
278+
{
279+
InitializeComponent();
280+
MyReactiveClass = new MyReactiveClass();
281+
}
282+
}
283+
```
284+
254285
### TODO:
255286
- Add ReactiveCommand with parameterised Attribute pass through
256287
- Add ObservableAsProperty to generate from a IObservable creating a property and the property helper wired to the Observable.

0 commit comments

Comments
 (0)