Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/299.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何更新其他项目视图模型(UWP)中的绑定属性?_C#_Uwp_Reactiveui - Fatal编程技术网

C# 如何更新其他项目视图模型(UWP)中的绑定属性?

C# 如何更新其他项目视图模型(UWP)中的绑定属性?,c#,uwp,reactiveui,C#,Uwp,Reactiveui,我有UWP UI项目和其他带有逻辑视图模型的.NET标准项目。我将字符串从viewmodel绑定到视图 <TextBlock Text="{Binding ConsoleData}" HorizontalAlignment="Center" FontSize="18"/> 启动后,程序将与一起下降。因为viewmodel存在于其他项目中,所以不可能调用Core.Dispather。请告诉我,如何解决此问题?使用Reactive.UI O

我有UWP UI项目和其他带有逻辑视图模型的.NET标准项目。我将字符串从viewmodel绑定到视图

        <TextBlock Text="{Binding ConsoleData}" HorizontalAlignment="Center"
               FontSize="18"/>

启动后,程序将与一起下降。因为viewmodel存在于其他项目中,所以不可能调用Core.Dispather。请告诉我,如何解决此问题?

使用Reactive.UI ObserveOnRxApp.MainThreadScheduler解决

使用Reactive.UI ObserveOnRxApp.MainThreadScheduler解决
    [Reactive] public string ConsoleData { get; set; } = "";

    public TestViewModel()
    {
        _testLogicController = new TestLogicController();
        _testLogicController.OnMessage += OnMessageUpdate;
    }

    private void OnMessageUpdate(object sender, EventArgs args)
    {
        ConsoleData += (string)sender;
        ConsoleData += "\n";
    }