Note that there are some explanatory texts on larger screens.

plurals
  1. POHide objects/User Controls within WrapPanel?
    text
    copied!<p>I've got a <code>WrapPanel</code> which will contain several different custom <code>UserControls</code>. Depending on the scenario, I may need to filter down which <code>UserControls</code> are visible. My goal is that I can switch which controls are visible on the fly by showing/hiding the controls that need to be filtered - thus shifting the controls that are left showing, to the top-left of the panel.</p> <p>Right now I am simply setting the <code>Visibility</code> property of the control to <code>Visibility.Collapsed</code> when I don't want them to appear. I thought that because I was using a <code>WrapPanel</code>, the rest of the controls would shift to the top-left of the panel.</p> <p>Instead, after hiding some of the <code>UserControls</code>, the controls that <strong>are</strong> still visible stay exactly where they were before, and I am left with gaps between the controls that are still showing. I've opened my app in <strong>Silverlight Spy</strong>, and it shows that the <code>UserControls</code> are still actually there (which makes sense) but are simply invisible.</p> <p><strong>So my question is:</strong> Is there a way that I can show/hide <code>UserControls</code> within a <code>WrapPanel</code> which allows the <em>still-visible</em> <code>UserControls</code> to slide to their new positions (all shifting towards the top left - similar to a <code>StackPanel</code>)?</p> <p>I've debated removing the <code>UserControls</code> completely from the <code>WrapPanel</code> (I think this would work) and storing them in memory until they are needed. Then if I wanted to show/hide other controls, I would get them from my in-memory object. It seems like there should be a better way to do this though.</p> <p>If anyone has any suggestions or advice, it would be greatly appreciated. Thanks!</p> <p>-Lloyd</p> <p><strong>UPDATE:</strong> </p> <p><strong>XAML:</strong> (very simple)</p> <p><code>&lt;toolkit:WrapPanel x:Name="MyLayout" Height="300" HorizontalAlignment="Left" VerticalAlignment="Top" Width="400" /&gt;</code></p> <p><strong>Code-Behind:</strong> The UserControls are getting added dynamically:</p> <p><code>MyLayout.Children.Add(oUserControl)</code></p> <p>And they are getting set to collapsed dynamically as well:</p> <p><code>oUserControl.Visibility = Visibility.Collapsed</code></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload