Tat*_*ice 5 wpf model-view-controller xaml f#
尝试从C#迁移到F#(我第一次使用MVC而不是MVVM,所以我的术语可能已关闭),但最终我无法设置我的WPF\XAML DataContext,因此我可以绑定我的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>
Run Code Online (Sandbox Code Playgroud)
和以下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()
Run Code Online (Sandbox Code Playgroud)
XAML编辑器的Intellisense可以查看我的课程,您可以从以下屏幕截图中看到:

知道我做错了什么吗?
| 归档时间: |
|
| 查看次数: |
165 次 |
| 最近记录: |