Reactiveui: WP8 - WhenAny / WhenAnyValue

Created on 21 Sep 2014  路  4Comments  路  Source: reactiveui/ReactiveUI

I get a NotSupportedException (Unsupported expression type: 'Constant') when attempting to use a basic WhenAny or WhenAnyValue in a WP8 application. Am I missing something?

outdated

Most helpful comment

Your expression should be x => x.ToggleState

All 4 comments

@TeaMax Can you show a code sample?

Maybe it's something I'm doing. Here's an example below.

``` C#
public class MainViewModel : ReactiveObject
{
public PasswordViewModel PasswordViewModel { get; private set; }

    public MainViewModel()
    {
        PasswordViewModel = new PasswordViewModel();
    }
}

public class PasswordViewModel : ReactiveObject
{
    public ToggleState ToggleState { get; private set; }

    public PasswordViewModel()
    {
        ToggleState = new ToggleState();

        this.WhenAnyValue(x => ToggleState.Toggled)
            .Subscribe(x => Debug.WriteLine("Test"));
    }
}

public class ToggleState : ReactiveObject
{
    private bool _toggled;
    public bool Toggled
    {
        get { return _toggled; }
        set { this.RaiseAndSetIfChanged(ref _toggled, value); }
    }
}

```

Your expression should be x => x.ToggleState

Oh! Dang it, I knew that too. My bad. Thanks Paul!

Was this page helpful?
0 / 5 - 0 ratings