ReactiveUI 和 UWP – 这些 warnings/errors 绑定来自哪里?

ReactiveUI and UWP – Where do these warnings/errors on binding come from?

我正在尝试在 UWP 中创建我的第一个 ReactiveUI 应用程序,但遇到了一些我不知道该怎么做的意外 warnings/errors。

我在 UWP(最小版本 10/1809/17763,最大版本 10/2004/19041)应用程序中使用 ReactiveUI 版本 12.1.1。

我一直在遵循(尽管我认为我做对了)这里的说明:https://www.reactiveui.net/docs/handbook/data-binding/microsoft-store

页面定义如下:

<Page
    x:Class="UwpReactiveUiTest.Views.GridsView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:local="using:UwpReactiveUiTest.Views"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
    mc:Ignorable="d">

    <Grid>
        <Slider
            x:Name="slider"
            Maximum="50"
            Minimum="0"
            Value="25" />
    </Grid>
</Page>

这是页面的隐藏代码:

public sealed partial class GridsView : Page, IViewFor<GridsViewModel>
{
    public static readonly DependencyProperty ViewModelProperty =
        DependencyProperty.Register(
        nameof(ViewModel),
        typeof(GridsViewModel),
        typeof(GridsView),
        new PropertyMetadata(null)
        );

    public GridsViewModel ViewModel
    {
        get => (GridsViewModel)GetValue(ViewModelProperty);
        set => SetValue(ViewModelProperty, value);
    }

    object IViewFor.ViewModel
    {
       get => ViewModel;
       set => ViewModel = (GridsViewModel)value;
    }

    public GridsView()
    {
        this.InitializeComponent();
 
        ViewModel = new GridsViewModel();
    }
}

这是视图模型:

public class GridsViewModel : ReactiveObject
{
    private double _sliderValue;
    public double SliderValue
    {
        get => _sliderValue;
        set => this.RaiseAndSetIfChanged(ref _sliderValue, value);
    }

    public GridsViewModel()
    {
 
    }
}

当我运行应用程序一切正常;正如预期的那样,我在输出中收到很多“正在加载 DLL”消息,但仅此而已。

但是,一旦我将绑定添加到视图构造函数中,例如:

public GridsView()
{
    this.InitializeComponent();
 
    ViewModel = new GridsViewModel();

    this.WhenActivated(disposableRegistration =>
    {
        this.Bind(ViewModel,
        viewModel => viewModel.SliderValue,
        view => view.slider.Value)
        .DisposeWith(disposableRegistration);
    });
}

我在输出中得到这个:

Exception thrown: 'System.IO.FileNotFoundException' in System.Private.CoreLib.dll
Exception thrown: 'System.IO.FileNotFoundException' in System.Private.CoreLib.dll
Exception thrown: 'System.IO.FileNotFoundException' in System.Private.CoreLib.dll
Exception thrown: 'System.IO.FileNotFoundException' in System.Private.CoreLib.dll
Exception thrown: 'System.IO.FileNotFoundException' in System.Private.CoreLib.dll
Exception thrown: 'System.IO.FileNotFoundException' in System.Private.CoreLib.dll
LogHost: Initializing to normal mode
POCOObservableForProperty: The class UwpReactiveUiTest.Views.GridsView property slider is a POCO type and won't send change notifications, WhenAny will only return a single value!

我的问题是:

  1. 异常。 异常从何而来?can/should 我对此做了什么?
  2. POCO 警告。 为什么我会收到 POCO 警告,can/should 我该怎么做?
  1. 仅在启动时发生的异常已解决ReactiveUI 2395
  1. POCO 警告,这是一个警告,让您知道您的 属性 不会通知更改。它们可以被忽略。但是,如果您想知道为什么您的 属性 不会更新,这些警告通常会指示原因。我不知道您是否可以将其关闭,但这不是什么值得担心的事情。