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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:20:30+00:00 2026-05-16T18:20:30+00:00

I want a TreeView with checkboxes and I’m trying to follow this tutorial .

  • 0

I want a TreeView with checkboxes and I’m trying to follow this tutorial. However, in it, he creates all his content for the TreeView at runtime. I have an XML file that I have accessible as an XmlDataProvider in my XAML:

<XmlDataProvider Source="XmlData/Versions.xml" XPath="//*[count(*)=0]"
                 x:Key="versionsXml" />

I have a view model class with IsChecked and Name properties, and I want to use this to represent nodes in my XML:

<Versions>
  <Version name="1.0">
    <Version name="1.0.001" />
    <Version name="1.0.002" />
  </Version>
</Versions>

My TreeView will display leaf nodes (i.e., 1.0.001 and 1.0.002) with a checkbox. How can I populate my TreeView with not the XmlDataProvider‘s content directly, but rather a List<MyViewModel>? I can create a property in my DataContext that returns a List<MyViewModel>, then bind my TreeView to that property, but I don’t know how, in a C# property getter, to read in the XML data from the XmlDataProvider. When I use TryFindResource and cast the object result to XmlDataProvider, the Document and Data properties are null for my versionsXml resource (defined in <UserControl.Resources>).

  • 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-16T18:20:30+00:00Added an answer on May 16, 2026 at 6:20 pm

    After reading this thread, I did the following:

    <XmlDataProvider Source="XmlData/Versions.xml" XPath="//*[count(*)=0]"
                     x:Key="versionsXml" IsInitialLoadEnabled="True"
                     IsAsynchronous="False" />
    

    Then, in C# to access the XmlDataProvider data since the Data property was no longer null:

    var versions = new List<MyViewModel>();
    var dataProvider = TryFindResource("versionsXml") as XmlDataProvider;
    if (null == dataProvider)
    {
        return versions;
    }
    var nodes = dataProvider.Data as IEnumerable;
    if (null == nodes)
    {
        return versions;
    }
    foreach (XmlElement node in nodes)
    {
       ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a TreeView in excel 2007 with checkboxes. I want the checkboxes to
I have a treeview in my C# code. I want to replace all existing
I have a Treeview with populateOnDemand set to true. I want this treeview to
I'm working with application, which use TreeView. I want some nodes have checkBoxes, but
In my C# Windows Form Application, I have Treeview control with checkboxes. I want
I have a ASP.Net TreeView Control with Checkboxes along Child nodes. I want to
I have a treeview and i want no postback on click any childnodes.And i
I have a treeView , and i want to know if some node can
I have a treeView with many nodes. I want that some nodes change their
I have a database(3 tables). I want to build treeView. I don't know how

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.