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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:48:01+00:00 2026-06-10T18:48:01+00:00

I’m quite new to whole XAML thing. I need to create a table (grid)

  • 0

I’m quite new to whole XAML thing.

I need to create a table (grid) with constant number of rows and columns (e.g 2×5) and put a TextBlock in each cell.

How can I do this properly, so I can change the data of cells easily?

for example, I want to create a function which accepts 1 integer as offset:

void fillDate(int offset)

and fills the cells starting from offset incrementally.

i.e. calling the function with `fillData(3)’ for a 2×5 would generate the following table:

 | | |1|2
3|4|5|6|7 
  • 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-10T18:48:02+00:00Added an answer on June 10, 2026 at 6:48 pm

    It’s nothing special, and coming from a Silverlight/XAML background, but will probably more or less work. You might need to tweak for slight API differences (writing in notepad without VS handy) and untested, but should give you what you need to get started.

    private void fillDate(int offset)
    {
        int rows = 2;
        int columns = 5;
        int currentEntry = 1;
    
        for(int rowIndex = 0; rowIndex < rows; rowIndex++)
        {
            for (int columnIndex = 0; columnIndex < columns; columnIndex++)
            {
                if (currentEntry > offset)
                {
                    TextBlock textEntry = new TextBlock();
                    textEntry.Text = currentEntry.ToString();
                    Grid.SetRow(textEntry, rowIndex);
                    Grid.SetColumn(textEntry, columnIndex);
                }
                currentEntry++;
            }
        }
    }
    

    EDIT: Just realized that you might be wanting a TextBlock with no text in the “empty” cells, in which case substitute the inner loop’s code with:

    TextBlock textEntry = new TextBlock();
    Grid.SetRow(textEntry, rowIndex);
    Grid.SetColumn(textEntry, columnIndex);
    if (currentEntry > offset)
        textEntry.Text = currentEntry.ToString();
    currentEntry++;
    

    EDIT: Based on your comment, first run a method when you create your control to build the grid and populate all the textfields and store them in a listing of some sort:

    private int Rows = 2;
    private int Columns = 5;
    private TextBlock[][] TextEntries;
    
    private void CreateTextBlocks()
    {
        TextEntries = new TextBlock[Rows][];
        for (int rowIndex = 0; rowIndex < rows; rowIndex++)
        {
            entries[rowIndex] = new string[columns];
            for (int columnIndex = 0; columnIndex < columns; columnIndex++)
            {
                TextBlock textEntry = new TextBlock();
                Grid.SetRow(textEntry, rowIndex);
                Grid.SetColumn(textEntry, columnIndex);
                myGrid.Children.Add(textEntry);
    
                TextEntries[rowIndex][columnIndex] = textEntry;
            }
        }
    }
    

    Then subsequently run another method to alter the values as desired:

    private void fillDate(int offset)
    {
        int currentEntry = 1;
    
        for(int rowIndex = 0; rowIndex < Rows; rowIndex++)
        {
            for (int columnIndex = 0; columnIndex < Columns; columnIndex++)
            {
                TextBlock textEntry = TextEntries[rowIndex][columnIndex]
    
                if (currentEntry > offset)
                    textEntry.Text = currentEntry.ToString();
                else
                    textEntry.Text = String.Empty;
    
                currentEntry++;
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
I have thousands of HTML files to process using Groovy/Java and I need to
I'm trying to create an if statement in PHP that prevents a single post
I need to clean up various Word 'smart' characters in user input, including but

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.