gpt4 book ai didi

Caliburn.Micro、HelloScreens-示例

转载 作者:行者123 更新时间:2023-12-02 19:23:40 26 4
gpt4 key购买 nike

我正在尝试理解 Caliburn.Micro 附带的 HelloScreens 示例。 ShellView.xaml 在底部包含一个 ContentControl。有人可以解释一下这个元素的重要性吗?我尝试将其注释掉,但没有发现任何差异。

<UserControl x:Class="Caliburn.Micro.HelloScreens.Shell.ShellView"
xmlns:...>
<Grid>
<local:TiledBackground SourceUri="/Resources/Images/backgroundtexture.png" />
<Image Source="/Resources/Images/backgroundshadow.png"
Stretch="Fill" />

<ct:DockPanel>
<.../>
</ct:DockPanel>

<!-- Whats this one for? --/>
<ContentControl x:Name="Dialogs"
VerticalContentAlignment="Stretch"
HorizontalContentAlignment="Stretch"/>
</Grid>

</UserControl>

它绑定(bind)到 viewmodels Dialogs 属性,这是 IConductActiveItem 的自定义实现,但它有什么用呢?

最佳答案

每当您有 ContentControl与 View 模型属性同名,Caliburn.Micro 会找到该 View 模型对应的 View ,将 View 注入(inject) ContentControl ,并将 View 模型绑定(bind)到 View 。

在这种情况下,Dialogs属性是 IDialogManager按照您所说的输入,解析为 DialogConductorViewModel (导体类型)。所以DialogConductorView被注入(inject)到内容控件中。

此 View 显示应用程序中的对话框,如果您查看该 View ,它还有一个 ContentControl显示当前 ActiveItem 。这是 Caliburn.Micro 导体的典型特征。

<Controls:CustomTransitionControl x:Name="ActiveItem" Margin="8" />

请注意 DialogConductorView始终显示在 ShellView 中的应用程序内容上,但是Grid里面DialogConductorView仅当 ActiveItem 时才可见不为空。

<Grid Visibility="{Binding ActiveItem, Mode=TwoWay, 
Converter={StaticResource nullToCollapsed}}"

关于Caliburn.Micro、HelloScreens-示例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8350104/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com