简体   繁体   中英

<Viewport3D>: Hidden element identification

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;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM