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

The Archive Base Latest Questions

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

i have two separate classes namely: public class Floor { private string fname; public

  • 0

i have two separate classes namely:

    public class Floor { 
     private string fname;
   public Floor(string name)
   {
     fname = name;
   }

   public int FName
   {
      set { fname = value; }
      get { return fname; }
   }

}

public class Building 
{
   List<Floor> floors;
   string _bName;

   public Building(string bname)
   {

       _bName = bname;

      floors = new List<Floors>();

      for(int i = 0; i < 3; i++)
      {
           floors.Add(new Floor("floor" + (i + 1)));
      }
   }

   public string BName
   {
      set{ _bName = value; }
      get{ return _bName; }
   }

   public List<Floor> Floors
   {
      set { floors = value; }
      get { return floors; }
   }

}

in my XAML (MainPage.xaml):

<ListBox x:Name="lstBuilding" Background="White" Foreground="Black">
  <ListBox.ItemTemplate>
    <DataTemplate>
       <StackPanel Orientation="Horizontal" Margin="10,0,0,15">                  
           <StackPanel>
             <TextBlock Text="{Binding Path=BName }" />                                                                                      
            </StackPanel>
        </StackPanel>
    </DataTemplate>
  </ListBox.ItemTemplate>
</ListBox>

and in my XAML.cs (MainPage.xaml.cs)

ObservableCollection< Building > buildings = new ObservableCollection< Building>();

for(int i = 0; i < 2; i++)
{
    buildings.Add(new Building("building" + (i + 1)));
}

lstBuilding.ItemsSource = buildings

Here’s the question:

how can i access FName inside Floor class using XAML?
What i did is :

<TextBlock Text="{Binding Path=Floors.FName }" />  

but it didn’t work. 🙁

Sorry for the long post.

  • 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:00:26+00:00Added an answer on June 10, 2026 at 6:00 pm

    Your code itself is flawed because you are trying to access Floors which is again a Collection/List, When you have <TextBlock Text="{Binding Path=Floors.FName }" /> , it is not clear which floor are you referring to or what you are trying to do?

    If you want reference to the first floor only you can try <TextBlock Text="{Binding Path=Floors[0].FName }" />

    But incase you are trying to access data of each floor in each building you need to change the xaml for that to work. Its called Nested binding.

     <ListBox x:Name="listBuilding">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <ListBox ItemsSource="{Binding Floors}">
                                <ListBox.ItemTemplate>
                                    <DataTemplate>
                                        <TextBlock Text="{Binding Path=FName}"></TextBlock>
                                    </DataTemplate>
                                </ListBox.ItemTemplate>
                            </ListBox>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say I have two separate classes, A and B. I also have Repository class
Working in Java: I have a JFrame class, and separate classes for my two
I have two classes orchestrated by a main class and I would like to
I have created two separate objects, one of class Order and one of class
Let's say you have a class class C { int * i; public: C(int
I have my two class in two separate files, customer and address. Address is
I have two separate classes in css, and I want the links to switch
I have two classes (class A and B) both marked with [Binding]. Currently I'm
In the following code I have two classes, one that runs in a separate
I have two classes, Input, and EventSystem. EventSystem is an internal (non-system dependent) class

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.