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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:21:23+00:00 2026-05-17T01:21:23+00:00

I have two Grids inside a Stackpanel. The first grid is named as GridX.

  • 0

I have two Grids inside a Stackpanel.
The first grid is named as GridX.
Initially, inside the grid, there is a 2D array of Textboxes(RowDefs/ColumnDefs).
The TextBox definition in XAML is

<TextBox x:Name="A1" Grid.Row="4" Grid.Column="5" TextAlignment="Center" />

I want to add a TextBlock programmatically in the same position as part of GridX.

The effect must be like this

<TextBlock Grid.Row="4" Grid.Column="5"
HorizontalAlignment="Left" VerticalAlignment="Top" Text="10" FontSize="8"/>

How to add this.
I have tried this:

TextBlock tblock = new TextBlock();
GridX.SetColumn(tblock, cIndex);
GridX.SetRow(tblock, rIndex);

But failed.

Again I tried this:

int rIndex = Grid.GetRow(txtBox);
int cIndex = Grid.GetColumn(txtBox);                               

TextBlock tblock = new TextBlock();
tblock.VerticalAlignment = VerticalAlignment.Top;
tblock.HorizontalAlignment = HorizontalAlignment.Left;
tblock.FontSize = 8;
tblock.Text = rc[i, j - 1];

Grid.SetColumn(tblock, cIndex);
Grid.SetRow(tblock, rIndex);

txtBox.MaxLength = 1;    

Now the problem is that TextBlock is not visible. TextBox hides it.
I appreciate your help.

  • 1 1 Answer
  • 3 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-17T01:21:24+00:00Added an answer on May 17, 2026 at 1:21 am

    For attached properties you can either call SetValue on the object for which you want to assign the value:

    tblock.SetValue(Grid.RowProperty, 4);
    

    Or call the static Set method (not as an instance method like you tried) for the property on the owner type, in this case SetRow:

    Grid.SetRow(tblock, 4);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have two int array of images , i have implemented it in grid
I have a grid with two columns with width 3* and 1*. Inside the
I have these two itemtemplates of textboxes inside the gridview and i am trying
I have a Grid as a root container with two columns defined (There's only
I have two grids inside a TabItem and in the code-behind I want to
I have created a grid function using list control. There are two columns in
I have two grids with same number of rows ( also same height). Both
I have two grids, thay both have one store. I need to show everything
In .net objects like DataTable when you have two grids(Master and Detail) and add
I have two grid, one with auto-generated fields and the other not. how can

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.