0
我在auditInventoryViews后面的代码中写了一些东西:SchedulerView用户控件替换父内容控件的内容“DSViewContentControl” 我试过“this .content“,但它仅替换当前用户控件的内容,其他内容仍保留在用户控件中。如何在子代码后面的代码中替换父控件的内容
所以,事情是如何从代码后面的子代替父控件的内容。例如
<UserControl>
<ContentControl x:Name="DSViewContentControl" >
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" ></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<!-- region scheduler -->
<StackPanel Grid.Row="1" Grid.Column="1" Margin="40,5,0,0">
some content
</StackPanel>
<StackPanel Grid.Row="1" Grid.Column="1" Margin="40,5,0,0">
<auditInventoryViews:SchedulerView/>
</StackPanel>
</Grid>
</ContentControl>
</UserControl>
谢谢!你尝试了你的方法,并能够使用ContentControl DSViewContentControl =(ContentControl)(((Grid)((StackPanel)this.Parent)获得父内容控件。 – user2863825 2014-10-19 11:38:34