我希望在屏幕上同时显示2个控件,并允许它们相互独立地过渡。我使用的是Conductor.Collection.AllActive,但不知道如何在shell中同时显示列表控件(一个名为ProductListViewModel的屏幕)和详细信息屏幕(ProductViewModel)。
如何让它们加载到适当的ContentControls中?
<mah:TransitioningContentControl Grid.Row="2" Grid.Column="1"
Margin="5"
x:Name="NavigationFrame"/>
<mah:TransitioningContentControl Grid.Row="2" Grid.Column="2" Margin="5"
x:Name="ContentFrame" />
发布于 2019-05-10 21:47:42
我把它弄明白了,并认为它实际上很简单。对于要在其中放置独立视图的每个内容区域,ViewModel都需要一个IScreen属性。
所以,在这种情况下,它将是
public class ShellViewModel: Screen
{
private string _title = "Some title";
private Conductor<IScreen> _listConductor;
private Conductor<IScreen> _detailConductor;
public ShellViewModel()
{
_listConductor = new Conductor<IScreen>();
_detailConductor = new Conductor<IScreen>();
ListFrame = GetContainer().Resolve<ProductListViewModel>();
DetailFrame = GetContainer().Resolve<ProductViewModel>();
}
public string Title { get => _title; set => _title = value; }
public IScreen ListFrame
{
get { return _listConductor.ActiveItem; }
set {
_listConductor.ActivateItem(value);
NotifyOfPropertyChange(nameof(ListFrame));
}
}
public IScreen DetailFrame
{
get { return _detailConductor.ActiveItem; }
set {
_detailConductor.ActivateItem(value);
NotifyOfPropertyChange(nameof(DetailFrame));
}
}
等。
https://stackoverflow.com/questions/56060359
复制相似问题