【发布时间】:2015-09-11 09:05:39
【问题描述】:
我知道如果我执行以下操作,我可以在屏幕之间切换:
ShellViewModel.cs
public class ShellViewModel : Conductor<object>.Collection.OneActive
{
public void ShowFirstScreen()
{
ActivateItem(new FirstViewModel());
}
public void ShowSecondScreen()
{
ActivateItem(new SecondViewModel());
}
}
用于 OneActive 的 ShellView.xaml
<ContentControl x:Name="ActiveItem" />
但我想同时显示这些屏幕。因此,当从 OneActive 更改为 AllActive 时,屏幕不再可见。
我知道如果我使用 ItemsControl 可以显示这些屏幕
AllActive 的 ShellView.xaml
<ItemsControl ItemsSource="{Binding Path=Items}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<ContentControl cal:View.Model="{Binding}"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
但我想将它们随机放置在我的 ShellView.xaml 中。
怎么做?
如何访问它们?我想将它们像 UserControls 一样放在我的 ShellView.xaml 中。
<Grid>
<ContenControl x:Name="Item1 or even the ViewModel name"/>
<ContenControl x:Name="Item2 or even the ViewModel name"/>
...
</Grid>
【问题讨论】:
标签: c# wpf xaml caliburn.micro