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 8818803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:11:50+00:00 2026-06-14T05:11:50+00:00

I have a grid with columns and rows define. By knowing x amount of

  • 0

I have a grid with columns and rows define. By knowing x amount of items, I can add it to my xaml no problem. Unfortuantely I want to create the listview programatically because I want to populate them based on x amount of item I get when executing my SP. Here is my xaml. The label is there to assign a given content from the SP result too. Can someone show me how create this programatically?

<Grid Name="grdItems" Width="939" Grid.Row="1" HorizontalAlignment="Left" DataContext="{Binding}" Margin="5">
    <Grid.RowDefinitions>
        <RowDefinition Height="25"></RowDefinition>
        <RowDefinition Height="auto"></RowDefinition>
        <RowDefinition Height="5"></RowDefinition>
        <RowDefinition Height="25"></RowDefinition>
        <RowDefinition Height="auto"></RowDefinition>
        <RowDefinition Height="5"></RowDefinition>
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="231"></ColumnDefinition>
        <ColumnDefinition Width="5"></ColumnDefinition>
        <ColumnDefinition Width="231"></ColumnDefinition>
        <ColumnDefinition Width="5"></ColumnDefinition>
        <ColumnDefinition Width="231"></ColumnDefinition>
        <ColumnDefinition Width="5"></ColumnDefinition>
        <ColumnDefinition Width="231"></ColumnDefinition>
    </Grid.ColumnDefinitions>

    <Label Name="lblItem" Grid.Row="0" Grid.Column="0" Content="item label" />
    <ListView Name="lstFirstItem" HorizontalAlignment="Left" VerticalAlignment="Top" 
                    Height="auto" Margin="0,0,0,0" ItemsSource="" FontWeight="Regular" 
                    Grid.Column="0" Grid.Row="1">
        <ListView.View>
            <GridView>
                <GridView.ColumnHeaderContainerStyle>
                    <Style>
                        <Setter Property="FrameworkElement.Visibility" Value="Collapsed"/>
                    </Style>
                </GridView.ColumnHeaderContainerStyle>
                <GridViewColumn Width="58" DisplayMemberBinding="{Binding ItemName}"></GridViewColumn>
                <GridViewColumn Width="174.25" DisplayMemberBinding="{Binding ItemDescription}"></GridViewColumn>
            </GridView>
        </ListView.View>
    </ListView>
</Grid>
  • 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-06-14T05:11:52+00:00Added an answer on June 14, 2026 at 5:11 am

    we can add rows or columns dynamically from code behind.

    Inorder to add rows:

        GridLength rowheight = new GridLength(100);  //your own value we can give *,Auto as well  
        RowDefinition rowDef = new RowDefinition {Height = rowheight };    
        mainGrid.RowDefinitions.Add(rowDef);
    

    Inorder to add colomns:

        GridLength columnwidth = new GridLength(100);        
        ColumnDefinition colDef = new ColumnDefinition { Width = columnwidth};        
        mainGrid.ColumnDefinitions.Add(colDef );    
    

    Inorder to add textblock at particular row,column

        TextBlock textBlock = new TextBlock();        
        textBlock.Text = "Some Value";       
        Grid.SetRow(textBlock, rowNum);        
        Grid.SetColumn(textBlock, colNum);
        mainGrid.Children.Add(textBlock);  
    

    Hope this answers your question

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

Sidebar

Related Questions

i have a grid divided into several rows/columns, how can i get the canvas
I have a grid with 100 columns and 100 rows. I want to draw
Say I have a very simple WPF grid (6 rows x 6 columns) defined
I have a grid in my GWT application there are columns and rows which
I have grid something like this: Ext.define('Exp.view.dashboard.Tv', { extend: 'Ext.grid.Panel', initComponent: function() { this.columns
I have a grid view and I add columns to it by code: //Retrieve
I'm trying to have a regular grid rows and columns defined dynamically using databinding
I have a grid (6 rows, 5 columns): grid = [ [None, None, None,
I have quite annoying problem with hiding grid columns dynamically. After I hide columns
I have a grid (table) like structure with rows and columns, and I am

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.