Skip to content

Commit

Permalink
Update Readme for IViewFor (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisPulman authored Aug 4, 2024
1 parent 44b3366 commit 05fca0a
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@ These Source Generators were designed to work in full with ReactiveUI V19.5.31 a
- [Reactive]
- [ObservableAsProperty]
- [ReactiveCommand]
- [ReactiveCommand(CanExecute = nameof(IObservableBoolName))] with CanExecute
- [ReactiveCommand][property: AttribueToAddToCommand] with Attribute passthrough
- [IViewFor(nameof(ViewModelName))]

Versions older than V19.5.31 to this:
- [Reactive] fully supported,
- [ObservableAsProperty] fully supported,
- [ReactiveCommand] all supported except Cancellation Token asnyc methods.
- [ReactiveCommand] all options supported except Cancellation Token asnyc methods.

# Historical ways
## Read-write properties
Expand Down Expand Up @@ -251,6 +254,34 @@ public partial class MyReactiveClass
}
```

## Usage IViewFor `[IViewFor(nameof(ViewModelName))]`

### IViewFor usage

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.
The ViewModel is passed as a string to the IViewFor Attribute.
The class must inherit from a UI Control from any of the following platforms and namespaces:
- Maui (Microsoft.Maui)
- WinUI (Microsoft.UI.Xaml)
- WPF (System.Windows or System.Windows.Controls)
- WinForms (System.Windows.Forms)
- Avalonia (Avalonia)
- Uno (Windows.UI.Xaml).

```csharp
using ReactiveUI.SourceGenerators;

[IViewFor(MyReactiveClass)]
public partial class MyReactiveControl : UserControl
{
public MyReactiveControl()
{
InitializeComponent();
MyReactiveClass = new MyReactiveClass();
}
}
```

### TODO:
- Add ReactiveCommand with parameterised Attribute pass through
- Add ObservableAsProperty to generate from a IObservable creating a property and the property helper wired to the Observable.

0 comments on commit 05fca0a

Please sign in to comment.