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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T09:15:20+00:00 2026-06-10T09:15:20+00:00

I am working on a WPF project and I have a TreeView using HierarchicalDataTemplates

  • 0

I am working on a WPF project and I have a TreeView using HierarchicalDataTemplates. I have been able to establish some different levels of nodes. Everything is going well so far.

<TreeView Margin="14,14,14,14" Name="treeView" ItemsSource="{Binding Tree}"
                               BorderThickness="0">
                  <TreeView.Resources>
                    <!--
                        First Level
                    -->
                    <HierarchicalDataTemplate DataType="{x:Type vm:FirstLevelViewModel}" 
                                              ItemsSource="{Binding Children}" >
                        <StackPanel Orientation="Horizontal" >
                        <TextBlock Text="{Binding SomeText}" FontSize="14" FontWeight="Bold" Foreground="DarkBlue"  />
                        </StackPanel>                           
                    </HierarchicalDataTemplate>
                    <!--
                        Second Level
                    -->
                    <HierarchicalDataTemplate DataType="{x:Type vm:SecondLevelViewModel}" 
                                              ItemsSource="{Binding Children}" >
                            <CheckBox Name="checkBox" IsChecked="{Binding IsChecked}" IsEnabled="{Binding IsEnabled}">
                            <StackPanel Orientation="Horizontal">
                            <TextBlock Text="{Binding SomeText}" FontSize="14" />
                            </StackPanel>
                        </CheckBox>
                    </HierarchicalDataTemplate>
. . . . 

My problem is that: I need some nodes to be non collapsible.

Is there any way to achieve that? I have been searching about it with no luck.

  • 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-10T09:15:21+00:00Added an answer on June 10, 2026 at 9:15 am

    The default template of the TreeViewItem defines a ToggleButton which shows and hides the sub-items. You can create your own template based on that in which the IsEnabled property is bound to some property on your item, so that it can be prevented from being toggled, of course you should also bind the IsExpanded (can be done outside the template as well) and the value in that case should always be true.

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

Sidebar

Related Questions

I have been working on a C# 4.0 WPF project and need to figure
I've recently been working on a project using WPF to produce a diagram. In
I'm working on a solution where I have a WPF project that is using
I am currently working on a wpf project in C#. I have a treeview
I am working on a project on WPF and I have to create some
I am working on a WPF project and I have added a TreeView to
I have been working through a very small-scale WPF project in order to familiarize
I am working on a WPF MVVM Project. Now i have a DataGrid in
I'm working on a WPF project using MVVM and I'm trying to implement a
I am working on a WPF project, using MVVM and Microsoft Prism libraries .

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.