0
<UserControl x:Name="AView" .... />
public class AViewModel { .. }

<UserControl x:Name="ParentView">
  <UserControl.Resources>
    <DataTemplate DataType={x:Type vm:AViewModel}>
      <vw:AView />
    </DataTemplate>
  </UserControl.Resources>

  <Grid.ColumnDefinitions>
    <ColumnDefinition />
    <ColumnDefinition />
  </Grid.ColumnDefinitions>

  <ContentControl Content="{Binding PropertyA}" />
  <ContentControl Content="{Binding PropertyB}" Grid.Column="1" />
</UserControl

public class ParentViewModel
{
    public AViewModel PropertyA {get;set;}
    public AViewModel PropertyB {get;set;}
}

PropertyA 和 PropertyB 持有对不同 AViewModel 实例的引用。

问:如何在绑定到 PropertyA 和 PropertyB 的 ContentControl 中显示不同的 AView 实例?

4

1 回答 1

0

您发布的 XAML 将AView在每个ContentControl.

于 2013-03-31T21:52:50.183 回答