0

I use reactiveUI for watching properties of DP The code is

/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
    public MainWindow()
    {
        RxApp.DeferredScheduler = DispatcherScheduler.Current;
        InitializeComponent();
        this.WhenAny(i => i.Width, i => i.Value).Subscribe(_ => SomeMethod("Width"));
        this.WhenAny(i => i.Height, i => i.Value).Subscribe(_ => SomeMethod("Height"));
    }

    void SomeMethod(string hello)
    {
        MessageBox.Show(hello);
    }

}

When I resize window by height there is no messagebox But when I resize window by width there is two messageboxes When I comment any of these whenany's it works very well, but with two whenanys work improperly

I know I can watch two propeties by one whenany but I need to watch two dependency properties of differentType by two WhenAny

How can I do this?

takayoshi
  • 2,789
  • 5
  • 36
  • 56
  • Have you tried listening for ActualWidth and ActualHeight. My guess is Width and Height are not changing similar because of your window resizing behavior, ActualXYZ should work no matter what. – dowhilefor Dec 21 '12 at 10:52
  • No. It works the same way. The problem is two whenany on one object. I'm waiting for Paul Betts' answer – takayoshi Dec 21 '12 at 11:19
  • I'm used to using RXUI in a view model that inherits from ReactiveObject, perhaps that's an approach you can use? – kenny Dec 21 '12 at 12:09
  • http://stackoverflow.com/questions/13910958/reactiveui-whenany-on-dependency-property – kenny Dec 21 '12 at 12:11
  • @kenny it's my question and it is question about another theme. And I can't use ReactiveObject in above question – takayoshi Dec 21 '12 at 12:45

1 Answers1

1

Hm. Can you file this bug over at http://github.com/reactiveui/reactiveui/issues? In the meantime, you might have to use a shim, something like:

var changedObservable = new Subject<Unit>();
this.SizeChanged += (o,e) => changedObservable.OnNext(Unit.Default);
Ana Betts
  • 73,868
  • 16
  • 141
  • 209