reactiveui whenany on dependency property

三世轮回 提交于 2019-12-11 14:36:33

问题


I have simple WPF app with two textboxes and ReactiveUI. I try to lookup for dependency property of first textbox by using WhenAny

 public partial class MainWindow : Window
{
    public MainWindow()
    {
        RxApp.DeferredScheduler = DispatcherScheduler.Current;
        InitializeComponent();
        Text1.WhenAny(i => i.Text, i => i.Value).Subscribe(_ => SomeMethod());

    }

    void SomeMethod()
    {
        MessageBox.Show("Boom!");
    }

}

My Form code is

<Window x:Class="TestObservable.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="350" Width="525">
<Grid>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*"></ColumnDefinition>
        <ColumnDefinition Width="*"></ColumnDefinition>
    </Grid.ColumnDefinitions>
    <TextBox Name="Text1" Grid.Column="0"></TextBox>
    <TextBox Name="Text2" Grid.Column="1"></TextBox>

</Grid>

BUT When I change TextBox Text it doesn't show to me

What's the problem?


回答1:


Try this:

this.WhenAny(x => x.Text1.Text, x => x.Value);

If it doesn't work, I believe you're being bitten by a bug in ReactiveUI 4.1. Upgrading to 4.2 (released a few days ago) may fix it.



来源:https://stackoverflow.com/questions/13910958/reactiveui-whenany-on-dependency-property

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!