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

  • Home
  • SEARCH
  • 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 8743083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:36:48+00:00 2026-06-13T11:36:48+00:00

I have two objects Exercise and Objective, each Exercise has one Objective. In the

  • 0

I have two objects Exercise and Objective, each Exercise has one Objective.
In the code behind I set the ItemsSource of the Exercises DataGrid

 dgExercicios.ItemsSource = Repositorio<Exercicio>.GetAll();

And in my XAML.

    <DataGrid Name="dgExercicios" CellStyle="{StaticResource CellStyle}" CanUserSortColumns="True" CanUserResizeColumns="True" AutoGenerateColumns="False">
         <DataGrid.Columns>
             <!--This bind works (Exercice.Nome)-->
             <DataGridTextColumn Header="Nome" Binding="{Binding Nome}" Width="200"   />
             <!--This bind DONT works (I Trying to bind to Exercise.Objective.Descricao)-->                     
             <DataGridTemplateColumn Header="Objetivo"  Width="80" >
                     <DataGridTemplateColumn.CellTemplate>
                         <DataTemplate  >
                             <StackPanel>
                                 <TextBlock Text="{Binding Path=Objective.Descricao}" T />
                              </StackPanel>
                          </DataTemplate>
                     </DataGridTemplateColumn.CellTemplate>
                 </DataGridTemplateColumn>
          </DataGrid.Columns>
      </DataGrid>

What I want to do is to bind the property Exercise.Objective.Descricao to the TextBlock on the Exercice.Nome

Another question, will a DataGridTemplateColumn be needed in this case?

  • 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-13T11:36:49+00:00Added an answer on June 13, 2026 at 11:36 am

    Well it will work if the Exercise class has a property called Objective, and the Objective class has a property called Descricao.

    public class Exercicio
    {
        public string Nome { get; set; }
        public Objective Objective { get; set; }
    
        public Exercicio(string nome, Objective objective)
        {
            this.Nome = nome;
            this.Objective = objective;
        }
    }
    
    public class Objective
    {
        public string Descricao { get; set; }
    
        public Objective(string d)
        {
            this.Descricao = d;
        }
    }
    
    public MainWindow()
    {
        InitializeComponent();
    
        var items = new ObservableCollection<Exercicio>(new[] {
            new Exercicio("Exercicio1", new Objective("Objective1")),
            new Exercicio("Exercicio2", new Objective("Objective2")),
            new Exercicio("Exercicio3", new Objective("Objective3"))
        });
    
        dgExercicios.ItemsSource = items;
    }
    

    And you don’t need a DataGridTemplateColumn if you just want to show a string:

    <!-- Works now (also in a normal text column) -->
    <DataGridTextColumn Binding="{Binding Path=Objective.Descricao}" Header="Objetivo" Width="80" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two objects - one that contains some code with will fire an
I have two objects, each with locally defined types, and I want to determine
I have two Objects, one is called CollidableController and the other is Collidable. Collidable
I have two objects of a class. I need to compare each field with
I have two objects - ContentPage , which has a collection of ChildLinks .
I have two objects: ObjectA { string code; string country; } ObjectB { string
I have two objects, let's call them Input and Output Input has properties Input_ID
I have two objects that are searching for one-another on the stage. They move
I have two objects: Color and Palette. Each palette can get a range of
I have two objects... and if I compile a program with either one, it

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.