0

I am trying to build a UI using Avalonia. I have been plowing through it, but I hit a snag. This is the example code they provide:

using ReactiveUI;

public class MyViewModel : ReactiveObject
{
    private string caption;

    public string Caption
    {
        get => caption;
        set => this.RaiseAndSetIfChanged(ref caption, value);
    }
}

I need to set properties to "RaiseAndSetIfChanged", which require setting the get; set; of the variable within the class. I'm not sure how to do this in Powershell.

I have tried things like this:

Powershell class implement get set property

To no avail, but maybe I wasn't doing it right.

Alternatively, if there would be a different way to set RaiseAndSetIfChanged after [MyViewModel]::New() was called

Link to Example:

https://avaloniaui.net/docs/binding/change-notifications

Jacob Kucinic
  • 115
  • 10

1 Answers1

0

I figured out how to use ReactiveUI in a different way, I give examples in the readme in this fork I have created of the module of Avalonia for Powershell.

https://github.com/MaynardMiner/psavalonia

It has a method called RaisePropertyChanged. I used it as a workaround to update bindings.

There is no possible way to natively create a getter/setter for C# emulation after searching.

Jacob Kucinic
  • 115
  • 10