如何使用WPF页面之类的页面?
在WPF中,我们有一个page
类,该类允许我们在单个窗口中使用多页接口。如何在阿瓦洛尼亚做?
In WPF, we have a Page
class that allows us to use a multi-page interface in a single window. How to do it in Avalonia?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您所描述的通常用
tabControl
来解决。每个选项卡可以具有
TabViewModel
派生的类实例,以绑定到其数据上下文。然后,这些可以拥有自己的视图
*。axaml
文件...tabaview.axaml
&tabbview.axaml
在此实例中。它们可以包含任何任意UI。完整的内容屏幕或PATH
的屏幕。然后,您可以将
tabControl
绑定的收集集合在一起,因此在类似于mainviewModel.cs
的东西上然后看起来像这样。
现在被警告。这是伪代码,但它解释了概念以及如何融合在一起。我在WPF和Avalonia中做到了这一点。
为什么要伪代码?
根据您使用的框架,它们将大大更改有关如何执行此操作的实现详细信息。
在
prism
中,您需要实现regionAdaptor
,在Avalonia中,您可能需要一个dataTemplatesElector
来接线>ViewModels
,在WPF中,这或多或少地算出了框。无论哪种方式,每个概念在每个概念中都是有效的。
What you're describing is often solved with a
TabControl
.Each tab can have a
TabViewModel
derived class instance to bind to as its data context.These can then have their own views
*.axaml
files ... soTabAView.axaml
&TabBView.axaml
in this instance. They can contain any arbitrary UI. Full screens of stuff or as little as aPath
.You can then have a collection of those that the
TabControl
binds too, so on something akin to aMainViewModel.cs
...MainView.axal
would then look like this.Now be warned. This is pseudocode, but it explains the concepts and how things can hang together. I've done this in WPF and Avalonia.
Why Pseudocode?
Depending on what frameworks you are using they would drastically change the implementation details on how to do this.
In
Prism
you would need to implement aRegionAdaptor
, in Avalonia you'd possibly need aDataTemplateSelector
to wire upViews
toViewModels
, in WPF this just more or less works out the box.Either way, the concept is valid in each.