愚蠢的F#\WPF错误 - “名称'abc'在命名空间'xyz'中不存在”,尽管Intellisense看到它。

5
尝试从C#迁移到F#(第一次使用MVC而不是MVVM,所以我的术语可能有误),但最终我无法设置我的WPF\XAML数据上下文,因此我无法绑定我的UI。
我有以下简单的WPF:
<UserControl x:Class="epic.Sandbox.Controls.FieldController"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:epic.Sandbox.Controls"
             xmlns:Views="clr-namespace:epic.View;assembly=epic.Core"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.DataContext>
        <Views:TextFieldModel />
    </UserControl.DataContext>
    <Grid>

    </Grid>
</UserControl>

还有下面的F#:

namespace epic.View

open System
open FSharp.Desktop.UI

[<AbstractClass>]
type public FieldModelBase() = 
    inherit Model() 

    let mutable fieldCaption: string = null
    let mutable fieldValue: System.Object = null
    [<DerivedProperty>]
    member this.Caption with public get() = sprintf "%s" fieldCaption and set value = fieldCaption <- sprintf "%s" value; this.NotifyPropertyChanged "Caption"
    [<DerivedProperty>]
    member this.Value with public get() = fieldValue and set value = fieldValue <- value; this.NotifyPropertyChanged "Value"

type public TextFieldModel() =
    inherit FieldModelBase()

XAML编辑器的Intellisense确实看到了我的类,您可以从以下屏幕截图中看到: Cropped 但是当我尝试编译时,我收到以下错误: Cropped2 有任何想法我做错了什么吗?

3
对于MVVM,你可以尝试使用FSharp.ViewModule。 - s952163
4
在您手动删除回收站内容并重建代码库后,您是否仍然遇到此问题?另外,请验证 epic.View 是否已在需要的所有位置显式声明。 - Terrance
谢谢@Terrance,就是这样。感到有些尴尬,但也很感激。 - turkinator
这很酷,我也经常遇到这种情况。 :) - Terrance
1个回答

3

感谢@Terrance的评论,我手动删除了WPF解决方案中的“\ bin”文件夹,重新启动了Visual Studio并重建了我的解决方案。问题已解决。我真是太傻了。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接