我有一个 XAML 布局:
<f:FlipPanel x:Name="flipper" Height="90" Width="90">
<f:FlipPanel.Front>
<Canvas x:Name="Empty_Frame" Visibility="Visible">
<Path Stroke="#FFBCC2AB" StrokeThickness="2">
<Path.Data>
<GeometryGroup FillRule="EvenOdd">
... <!-- There are a lot of geometric elements -->
</Canvas>
</f:FlipPanel.Front>
<f:FlipPanel.Back>
... <!-- There are a lot of geometric elements -->
</f:FlipPanel.Back>
</f:FlipPanel>
FlipPanel 是一个复杂的组件,取自第三方库。在执行期间,我需要<Canvas>
用另一组元素替换 。“搜索删除”代码不起作用:
var ecanvas = flipper.Children.OfType<Canvas>().FirstOrDefault(x => x.Name == "Empty_Frame");
flipper.Children.Remove(ecanvas);
原因在于隐藏的中间元素<Viewport3D>
,它位于面板上。
问题:如何获得指向此隐藏元素的链接以使用它(添加和删除元素)?