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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T07:38:52+00:00 2026-05-24T07:38:52+00:00

I have the following code which supposed to display a TreeView (the original code

  • 0

I have the following code which supposed to display a TreeView (the original code is more complicated, thus the complex control hirerchy):

<TreeView ItemsSource="{Binding TreeRoot}"
      HorizontalAlignment="Left">


    <TreeView.Resources>

        <DataTemplate x:Key="CTemplate">
            <Border >

                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="auto"/>
                    </Grid.ColumnDefinitions>

                    <ToggleButton 
                            Grid.Column="1"
            x:Name="Expander"
                            HorizontalAlignment="Right"
                            ClickMode="Press"/>                                          


                    <TextBlock  Text="{Binding Name}" 
                Grid.Column="0" />
                </Grid>

            </Border>
            <DataTemplate.Triggers>
                <DataTrigger Binding="{Binding Path=HasItems, RelativeSource={RelativeSource AncestorType={x:Type TreeViewItem}}}" Value="False">
                    <Setter TargetName="Expander" Property="Visibility" Value="Hidden"/>
                </DataTrigger>
            </DataTemplate.Triggers>

        </DataTemplate>



        <Style TargetType="{x:Type TreeViewItem}" x:Key="aaa">
            <Setter Property="ItemsSource" Value="{Binding Children}"/>
    <Setter Property="IsExpanded" Value="{Binding Path=IsExpanded,Mode=TwoWay}"/>                


            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type TreeViewItem}">
                        <StackPanel>
                            <Border Name="Bd"
                                        Background="{TemplateBinding Background}">

                            </Border>
                            <ItemsPresenter x:Name="ItemsP" />
                        </StackPanel>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsExpanded" Value="false">
                                <Setter TargetName="ItemsP"
                                        Property="Visibility"
                                        Value="Collapsed"/>
                            </Trigger>

                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>

        </Style>

        <Style TargetType="{x:Type TreeView}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type TreeView}">
                        <Border BorderBrush="{TemplateBinding BorderBrush}"
                                    BorderThickness="{TemplateBinding BorderThickness}">
                             <DockPanel>
                                    <ItemsPresenter/>
                                </DockPanel>

                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
            <Setter Property="ItemContainerStyle" Value="{StaticResource aaa}" />
            <Setter Property="ItemTemplate" Value="{CTemplate}" />
        </Style>
    </TreeView.Resources>
</TreeView>

Could you please help me figure out why my items are not displayed?
(The page appears empty)

Thanks,
Li

  • 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-24T07:38:53+00:00Added an answer on May 24, 2026 at 7:38 am

    You don’t have anything showing the Header of the TreeViewItem:

    <Style TargetType="{x:Type TreeViewItem}" x:Key="aaa">
        ...
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TreeViewItem}">
                    <StackPanel>
                        <Border Name="Bd" Background="{TemplateBinding Background}">
                            <ContentPresenter x:Name="PART_Header"
                                              ContentSource="Header"
                                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                        </Border>
                        <ItemsPresenter x:Name="ItemsP" />
                    </StackPanel>
                    ...
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    

    Above I added the ContentPresenter.

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

Sidebar

Related Questions

I have the following code, which is supposed to try to parse a given
I have the following code which is supposed to be removing a particular email
i have the following code, which is supposed to give specific functionality but it
I have the following code which does what it's supposed to do: objSQLCommand =
I have the following code which is supposed to increment a field value by
I have the following code, which is supposed to add a shared_ptr instance to
I'm trying to use opengl in C#. I have following code which fails with
I have following Code Block Which I tried to optimize in the Optimized section
I have the following code which works just fine when the method is POST,
I have the following code which works fine. However, I only want to return

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.