0

I am looking for a way to make the UserControl fill each line without letting a blank zone at the end of the line.

window with blank at the end of the line

That's my WrapPanel:

<ScrollViewer VerticalAlignment="Stretch" Margin="100,315,100,0" VerticalScrollBarVisibility="Auto" >
    <WrapPanel>
        <Border Margin="10,10,0,0" Width="200" Height="200" CornerRadius="15,15,15,15" BorderThickness="1,1,1,1" BorderBrush="#FF0A5952" Background="#7F95D4C3" MouseEnter="Border_MouseEnter" MouseLeave="Border_MouseLeave" Cursor="Hand" MouseDown="Border_Coran_MouseDown">
            <Grid >
                <Image Source="/tile_quran.png" Margin="5,5,5,15"></Image>
                <Label Content="Coran" HorizontalAlignment="Center" VerticalAlignment="Bottom" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" FontFamily="Verdana" FontSize="18" Foreground="#FF524E44"/>
            </Grid>
        </Border>
    </WrapPanel>
</ScrollViewer>

Does anyone know how to do that?

P.S.: The window can be resized so it needs to change every time we resize the window to fit perfectly each line.

Peter Csala
  • 17,736
  • 16
  • 35
  • 75
  • What is expected behavior? When you resize the window, what should happens with content? Do you want children to [stretch](https://stackoverflow.com/q/8004981/1997232)? – Sinatr Jun 21 '21 at 09:49
  • That there is not a big end space in the end of each line, you know after the last usercontrol of a line and before the scrollbar, so maybe we can increase the space between other usercontrol so this space dont exist? – thecoureurdu23 Jun 21 '21 at 09:50
  • And at a certain point it should jump to four items per row? That is not how WrapPanel works. You may want to take a look UniformGrid. – Clemens Jun 21 '21 at 09:56
  • Also consider using a ListBox, or an ItemsControl in a ScrollViewer. Set the ItemsPanel of the ListBox/ItemsControl to a WrapPanel or UniformGrid. – Clemens Jun 21 '21 at 09:58
  • How do I set a usercontrol in the second row of the first colum for exemple in my unformGrid? – thecoureurdu23 Jun 21 '21 at 10:05
  • You just add elements to the Children collection, exactly as you do with a WrapPanel. You would have to set the number of columns to a fixed value, e.g. ``. Take a look at the online documentation for details. – Clemens Jun 21 '21 at 10:07

0 Answers0