我有一个窗口,它使用 ReactiveUI 交互打开第二个窗口作为模式对话框,然后从第二个窗口中的 ListBox 返回数据。
问题是当 .ShowDialog() 完成时,ViewModel 的 SelectedItem 总是评估为 null。我已经确认绑定工作正常,并且所选项目正在对话框窗口的 ViewModel 中正确更新。只有当我返回到交互时,属性才会重置为其默认值 (null)。
我在这里整理了一个最小的问题示例:
https://github.com/replicaJunction/ReactiveDialogTest
被测的主要逻辑在 MainWindowViewModel.cs 中。
编辑:这是代码中的一个片段,其基本思想是:
GetNumberFromDialog = new Interaction<Unit, int>();
GetNumberFromDialog.RegisterHandler(interaction =>
{
var vm = new DialogWindowViewModel();
// Get a reference to the view for this VM
var view = Locator.Current.GetService<IViewFor<DialogWindowViewModel>>();
// Set its VM to our current reference
view.ViewModel = vm;
var window = view as Window;
var dialogResult = window.ShowDialog();
// At this point, vm.SelectedNumber is expected be the number the …Run Code Online (Sandbox Code Playgroud) 我正在尝试将“Hello ML.NET World”示例从 C# 转换为 F#(代码复制如下),但收到有关不兼容类型的 F# 编译器错误。
我看过一些关于 ML.NET 和 F# 的博客文章,但它们都使用旧的 API,其中涉及显式创建 LearningPipeline 对象。据我所知,该 API 已被删除。
C# 中有问题的行是训练管道的行:
var pipeline = mlContext.Transforms.Concatenate("Features", new[] { "Size" })
.Append(mlContext.Regression.Trainers.Sdca(labelColumnName: "Price", maximumNumberOfIterations: 100));
Run Code Online (Sandbox Code Playgroud)
我尝试将其转换为 F#,如下所示:
let pipeline (mlContext:MLContext) =
mlContext.Transforms
.Concatenate("Features", [| "Size" |])
.Append(mlContext.Regression.Trainers.Sdca(labelColumnName = "Price", maximumNumberOfIterations = Nullable(100)))
Run Code Online (Sandbox Code Playgroud)
但是,我收到编译器错误:Type constraint mismatch: The type 'Transforms.ColumnConcatenatingEstimator' is not compatible with the type IEstimator<ITransformer>'。
我还尝试将 ColumnConcatenatingEstimator 显式向下转换为 IEstimator:
let pipeline' (mlContext:MLContext) =
let concat = mlContext.Transforms.Concatenate("Features", [| "Size" …Run Code Online (Sandbox Code Playgroud)