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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T10:24:36+00:00 2026-05-19T10:24:36+00:00

I currently am trying to bind my business object to a treeview as the

  • 0

I currently am trying to bind my business object to a treeview as the root. And its collection property as the child. [I want to achieve this via BINDING]

Something like this.

public object MyBusinessObject
{
   private int _number;
   private bool _isSelected;
   private ObservableCollection<AnotherObject> _other = new ObservableCollection<AnotherObject>();


   public int Number { get {return _number;} set {_number = value;}}
   public bool IsSelected{ get {return _isSelected;} set {_isSelected= value;}}
   public ObservableCollection<AnotherObject>  Children { get {return _other;}}

}

I want my treeview to be represented like this:

  • “CheckBox binded to IsSelected” “Text binded to Number”
    • List of child binded to my “Children”
    • List of child binded to my “Children”
    • List of child binded to my “Children”
  • “CheckBox binded to IsSelected” “Text binded to Number”
    • List of child binded to my “Children”
    • List of child binded to my “Children”
    • List of child binded to my “Children”

I have no idea how to do this in xaml:

  <TreeView x:Name="_tv" ItemsSource="{Binding Path=MyBusinessObject}" >

            <TreeView.Resources>
                <HierarchicalDataTemplate> 
                    <CheckBox Content="{Binding Path=Number} IsChecked="{Binding Path=IsSelected}" />
                </HierarchicalDataTemplate>

                <HierarchicalDataTemplate ItemsSource="{Binding Path=Children}">
                    <TextBlock Text="{Binding Path=Name}" />
                </HierarchicalDataTemplate>
            </TreeView.Resources>
        </TreeView>

I know the above is not right, but i was wondering if there is a way to do this properly.

Thanks and Regards,

  • 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-05-19T10:24:37+00:00Added an answer on May 19, 2026 at 10:24 am

    Sure, you can use the HierarchicalDataTemplate.ItemTemplate property to define the data template to be used for the collection of AnotherObject instances.

    <TreeView ItemsSource="{Binding SomeCollectionOfObjects}">
        <TreeView.ItemTemplate>
            <HierarchicalDataTemplate ItemsSource="{Binding Children}">
    
                <!-- This is used for your AnotherObject instances -->
                <HierarchicalDataTemplate.ItemTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding Name}" />
                    </DataTemplate>
                </HierarchicalDataTemplate.ItemTemplate>
    
                <!-- This is used for your MyBusinessObject instances -->
                <CheckBox Content="{Binding Number}" IsChecked="{Binding IsSelected}" />
    
            </HierarchicalDataTemplate>
        </TreeView.ItemTemplate>
    </TreeView>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently trying to bind to certain items in a collection in wpf. This
I am currently trying to bind a collection of objects to a Canvas in
I am currently trying to bind an entity to a form however I want
I'm currently trying to design a property system, to bind member variables of a
I am currently trying to figure out how you can bind multiple fields in
Ok i am trying to build a grammar and currently it looks like this:
Im currently trying to bind the DataGrid.ItemsSource to a custom RowCollection, which implements IList
I'm trying to bind data from my SQLiteDatabase to a ListView . I'm currently
I am trying to bind to a property while inside a XAML 'property setter'.
Currently trying at add ajax to a site, after much reading I discovered that

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.