tags:

views:

537

answers:

1

If I am inserting elements into a wrap panel and there is still space in the panel before it overflows on the next line, can I specifically make it wrap over so that the subsequent elements are on the next line?

I am looking for something like this:

<WrapPanel>
  <Element/>
  <Element/>

  <NewLine???/>

  <Element/>
  <Element/>
  <Element/>
</WrapPanel>
+7  A: 

This works:

<WrapPanel>
    <TextBlock>1</TextBlock>
    <TextBlock>2</TextBlock>
    <TextBlock>3</TextBlock>
    <TextBlock>4</TextBlock>

    <TextBlock Width="10000" Height="0" />

    <TextBlock>5</TextBlock>
    <TextBlock>6</TextBlock>
</WrapPanel>

I have to add though... this is pretty much a hack. You might want to consider using a StackPanel, and inside of that, have a WrapPanel with the items you want to Wrap... Example:

<StackPanel>
    <WrapPanel>
     <TextBlock>1</TextBlock>
     <TextBlock>2</TextBlock>
     <TextBlock>3</TextBlock>
     <TextBlock>4</TextBlock>
    </WrapPanel>
    <WrapPanel>
     <TextBlock>5</TextBlock>
     <TextBlock>6</TextBlock>
    </WrapPanel>
</StackPanel>
Timothy Khouri