Trying to migrate from C# to F# (and my first time using MVC instead of MVVM, so my terminology may be off), but ultimately I'm unable to get my WPF\XAML DataContext set up, so I can bind my UI.
I have the following simple 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>
and the following 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()
The XAML editor's Intellisense DOES see my class, as you can see from the following screenshot:
But when I try to compile, I receive the following error:
Any idea what I'm doing wrong?
Thanks to the comment from @Terrance, I manually deleted my "\bin" folder from the WPF solution, restarted Visual Studio and rebuilt my solution. Problem solved. Silly me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With