I have a XAML layout:
<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 is a complex component taken from a third-party library. During execution, I need to replace the <Canvas>
with another set of elements.
"Search-delete" code does not work:
var ecanvas = flipper.Children.OfType<Canvas>().FirstOrDefault(x => x.Name == "Empty_Frame");
flipper.Children.Remove(ecanvas);
The reason lies in the hidden intermediate element <Viewport3D>
, which is located on the panel.
Question: How can I get a link to this hidden element to work with it (add and remove elements)?
I don't know how FlipPanel works, but actually you don't add Canvas to its Children collection, but put it to FlipPanel's 'Front' property. If you want to remove canvas, try the following:
flipper.Front = null;
And in order to put a new element there:
flipper.Front = myNewElement;