4

My problem is that my subscription to a nested property isn't responding.

Here's my XAML:

<TextBox Header="Enter test data:" 
         Text="{Binding UserEntryTest.Synced.Value, Mode=TwoWay}" />

The property in the view model (extract):

private EditableFieldSynced<string> userEntryTest;
public EditableFieldSynced<string> UserEntryTest
{
    get { return userEntryTest; }
    set { this.RaiseAndSetIfChanged(ref userEntryTest, value); }
}

The property Synced in EditableFieldSynced<T> is actually in a base class that inherits ReactiveObject:

public T _synced;
public T Synced
{
    get { return _synced; }
    set { this.RaiseAndSetIfChanged(ref _synced, value); }
}

And in its contructor I subscribe to Synced like this:

this.WhenAnyValue(x => x.Synced.Value) .Subscribe(x => this.ApplyLocalChanges(x));

Actually, whichever class I put in this subscription, it doesn't respond when the user inputs text...

I'm new to ReactiveUI, what am I doing wrong?

Of course, if I flatten the model with a property ValueSynced in EditableFieldSynced<T> that subscribes both ways to the changes of the based property Synced.Value, it does fire, but I'd like to get it done in an automated way -- if possible.

Milo
  • 3,365
  • 9
  • 30
  • 44
ericdes
  • 612
  • 1
  • 6
  • 12
  • Same for me. I have used code like this: https://www.reactiveui.net/docs/handbook/when-any/#null-propogation-inside-whenanyvalue – Evgeny Gorbovoy Nov 15 '22 at 01:28

0 Answers0