<DataTemplate DataType="{x:Type models:ViewModel}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<DockPanel HorizontalAlignment="Stretch" common:CustomAttachedProperties.IsAccessKeyScope="True">
<userControl:MyBanner DockPanel.Dock="Left" x:Name="UserBanner" EmergencyProtocolVisible="False" />
<userControl:PageSummary DockPanel.Dock="Top" x:Name="_adminSummaryWithFooter"/>
<userControl:Footer HorizontalAlignment="Stretch" VerticalAlignment="Bottom" x:Name="_myFooter" DataContext="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type userControl:PageSummary}}, Path=.}">
<userControl:Footer.InnerContent>
<StackPanel Background="Red" Height="300px" Width="500px">
</StackPanel>
</userControl:Footer.InnerContent>
</userControl:Footer>
</DockPanel>
</Grid>
</DataTemplate>
我需要在Footer元素中使用Viewmodel Icommand。如果我尝试这个DataContext="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type userControl:PageSummary}}, Path=.}
,无法找到元素。此外,我尝试使用ElementName
,其他控件中指定了名称。
使用Scoop的图片,需要将AdminSummary对象引用到Footer中:
请咨询