Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

142
Views
Bind elements to 2 different columns in a Z way

I have a mainview with a grid divided into two columns.

The issue is that I have an organized list of view models ( user controls with a textbox with different scopes ) that is created dynamically, and I want to display them in a Z way. I.e: from left to right, top to bottom ( see image )

enter image description here

At the moment i'm using something like the code above, dividing the list in the viewmodel into two different lists according to the element index.

<Grid>
<Grid.ColumnDefinitions>
    <ColumnDefinition Width="*" />
    <ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>

<Stackpanel Grid.Column=0>
  <ItemsControl.ItemTemplate>
    <DataTemplate DataType="EvenElements">
        <Border>
            <TextBlock Text="{Binding}" />
        </Border>
    </DataTemplate>
  </ItemsControl.ItemTemplate>
</Stackpanel> 

<Stackpanel Grid.Column=1>
  <ItemsControl.ItemTemplate>
    <DataTemplate DataType="OddElements">
        <Border>
            <TextBlock Text="{Binding}" />
        </Border>
    </DataTemplate>
  </ItemsControl.ItemTemplate>
</Stackpanel> 
</Grid>

Is there a way to do it in a single binding style? I don't want to join the textboxes input later because the index matters, and the code doesn't look that clean in that way. Thank you

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

If I understand your issue correctly, you could use an UniformGrid as the ItemsPanel of the ItemsControl:

<ItemsControl>
    <ItemsControl.ItemsPanel>
        <ItemsPanelTemplate>
            <UniformGrid Columns="2" />
        </ItemsPanelTemplate>
    </ItemsControl.ItemsPanel>
</ItemsControl>
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!