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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:21:17+00:00 2026-06-14T00:21:17+00:00

I am a newbie with DataGrid s in WPF C#. I have two DataGrid

  • 0

I am a newbie with DataGrids in WPF C#.

I have two DataGrids on two different tab controls.

Now one of them works (which means I am able to dynamically create and add columns and access datagrid1 and its methods)
While with other one datagrid2 I am not able to do the above in any private methods. (I copy pasted datagrid1 properties and renamed it datagrid2)
However with datagrid2, when I use inside the Windows_Loaded method, I am able to do these things.

What am I doing wrong?
Here’s the code:

<my3:DataGrid AutoGenerateColumns="False" CanUserAddRows="False" 
CanUserDeleteRows="False" Block.TextAlignment="Center" HeadersVisibility="Column"  
AlternationCount="2" ItemsSource="{Binding}" IsReadOnly="True" 
AlternatingRowBackground="LightYellow" Margin="6,57.772,12.489,6" Name="datagrid2" 
xmlns:my3="http://schemas.microsoft.com/wpf/2008/toolkit">
</my3:DataGrid>
  • 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-14T00:21:18+00:00Added an answer on June 14, 2026 at 12:21 am

    Generally speaking, never try to access and manipulate UIElements in the constructor.

    Instead, handle the Loaded event of your container (usually a UserControl, Control, Window, or Page) and manipulate your UIElements there.

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

Sidebar

Related Questions

newbie doing Java homework here. I have one class named Album which contains the
I have a dataset which i bind to datagrid from wpf toolkit(forced to use
I have such task - to create control that union two controls (DataGrid from
I'm a newbie with WPF and c# and have a (probably very simple) problem.
newbie question; I have two binary numbers; say for example; 0b11 and 0b00. How
Newbie question: I have a loop which places a number of elements on a
Newbie here, I have a struct for a word, which contains a char array
I am a newbie .net programmer learning WPF for past one month. One thing
newbie here, so thanks in advance for help! I have a Wordpress site with
Newbie question... The objective: I intend to have an HTML text input field as

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.