Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 584011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:51:12+00:00 2026-05-13T14:51:12+00:00

I have a grid with just 1 row. I would like the amount of

  • 0

I have a grid with just 1 row. I would like the amount of columns to be determined by the data context of the grid.

For instance, if I have a list of names exposed in an ObservableCollection property called ‘Names’ that return “Fred”, “Joe”, and “Anne”, I would like three columns in the grid, each with a textbox bound to each name.

My thoughts so far:

1) Build the grid by hand in the code-behind and rebuild it when the ObservableCollection changes. I didn’t go with this as it seemed a bit cludgy and not the WPF way of doing things.

2) Create a binding with the Grid’s ColumnDefinitions property. This seemed more correct, but there’s not a dependency property on the Grid for ColumnDefinition.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T14:51:13+00:00Added an answer on May 13, 2026 at 2:51 pm

    I don’t think modifying a Grid on the fly is your best bet. Here’s another solution. You can use ListBox, but replace the ItemsPanel with another panel of your choosing. ListBox’s default ItemsPanel is VirtualizingStackPanel with Orientation set to Vertical. Since you want your items to display horizontally, you can replace it with VirtualizingStackPanel with Orientation set to Horizontal. Of course, you can modify the ItemsTemplate or anything else as you see fit.

    <ListBox ItemsSource="{Binding MyCollection}">
        <ListBox.ItemsPanel>
            <ItemsPanelTemplate>
                <VirtualizingStackPanel Orientation="Horizontal"/>
            </ItemsPanelTemplate>
        </ListBox.ItemsPanel>
    </ListBox>
    

    I’ve also used this method before to create a ListBox which displays the items horizontally, but wraps to the next line when it runs out of room on the line, by using a WrapPanel. You can also create your own custom panels and substitute them. I once made a panel that laid out it’s items randomly, and used that for a ListBox. Each item in my bound collection was displayed in a random position within the ListBox. Each time the layout refreshed, the items got a new position.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have grid something like this: Ext.define('Exp.view.dashboard.Tv', { extend: 'Ext.grid.Panel', initComponent: function() { this.columns
My problem is I Have an isometric grid, just based on the X,Y values:
I have a <Grid> set up just the way I want with each cell
I have a grid of UIImageViews. The images names come from a sqlite3 database.
I have a DataGridView . I would like to update another cell on the
I have a gridview control with delete asp:ImageButton for each row of the grid.
I have a asp:DataGrid which holds data in two columns on my webpage. The
Is it possible to have a pure hierarchical wpf data grid? Now there are
I have a grid with 3 columns: title, content and date created. My largest
I have a simple grid layout which is just hosting several labels and textboxes.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.