是否可以在F#中创建一个使用经典的代码后台(即有code behind
)的WPF应用程序?我知道它与MVVM和无代码后台非常配合,但我需要在UserControl
上实现一个接口。在F#中是否可能?
为了帮助一下,这里是我想要从C#翻译成F#的代码:
public class Test : UserControl, IContent {
public void InitializeComponents() {
// Do the initialization magic
}
public Test() {
}
public void OnFragmentNavigation(FragmentNavigationEventArgs e) {
this.DataContext = new { description = "Hallo Welt :)" };
}
public void OnNavigatedFrom(NavigationEventArgs e) {
}
public void OnNavigatedTo(NavigationEventArgs e){
}
public void OnNavigatingFrom(NavigatingCancelEventArgs e) {
}
}
这是标记
,与此相关的是it技术。<UserControl xmlns="http://schemas.microsoft.com/netfx/2007/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="Test">
<TextBlock Text="{Binding description}"></TextBlock>
</UserControl>
UserControl
上的导航事件。我已经提出了一个问题,是否可以在ViewModel中完成它 ;) - Knerd