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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:56:26+00:00 2026-05-24T09:56:26+00:00

The following code throws an exception: <TreeView ItemsSource={Binding TreeRootInstance} x:Name=Htree ItemTemplate=CellTemplate SelectedItemChanged=HTree_OnSelectedItemChanged KeyDown=HTree_KeyDown> <TreeView.Resources>

  • 0

The following code throws an exception:

<TreeView 
            ItemsSource="{Binding TreeRootInstance}"
            x:Name="Htree"
            ItemTemplate="CellTemplate"
            SelectedItemChanged="HTree_OnSelectedItemChanged"
            KeyDown="HTree_KeyDown">

            <TreeView.Resources>

            <DataTemplate x:Key="CellTemplate">
                    <Border>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="auto"/>
                                <ColumnDefinition Width="auto"/>
                            </Grid.ColumnDefinitions>

                            <ToggleButton x:Name="Expander"
                                      HorizontalAlignment="Right"
                                      Focusable="False"
                                      Grid.Column="1"
                                      IsChecked="{Binding Path=IsExpanded, RelativeSource={RelativeSource AncestorType={x:Type vw:TreeViewItem}}}"
                                      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="aa">
                    <Setter Property="IsTabStop" Value="True"/>
                    <Setter Property="TabIndex" Value="0"/>
                    <Setter Property="IsExpanded" Value="{Binding Path=IsExpanded,Mode=TwoWay}"/>
                    <Setter Property="ItemsSource" Value="{Binding Children}"/>
                    <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type TreeViewItem}">
                            <StackPanel>
                                <Border Name="Bd">

                                </Border>
                                <ItemsPresenter x:Name="ItemsHost" />
                            </StackPanel>
                            <ControlTemplate.Triggers>
                                <Trigger Property="IsExpanded" Value="false">
                                    <Setter TargetName="ItemsHost"
                                            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}">

                            </Border>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
                    <Setter Property="ItemContainerStyle" Value="{StaticResource aa}" />
            </Style>

            </TreeView.Resources>
    </TreeView>

(I’ve omitted some of the code but the main hirerchy is still there…)
The exception is a xaml parse exception, on ItemsControl.ItemTemplate.

Could you please tell me how to make this code work?

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-24T09:56:28+00:00Added an answer on May 24, 2026 at 9:56 am

    You can’t use a plain string as a resource locator, you need to use either a StaticResource markup extension, i.e., ItemTempate="{StaticResource CellTemplate}"

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

Sidebar

Related Questions

The following code public class GenericsTest2 { public static void main(String[] args) throws Exception
The following code throws an exception in Powershell V1 (Excel 2007): $E = New-Object
The following code throws an exception... private void EnsureDiskSpace() { using (IsolatedStorageFile file =
The following simple code throws exception: entityManager.createQuery(SELECT c FROM Customer c); But if I
The following code for a co-worker throws the following error when he tries to
I have the following code in WCF service to throw a custom fault based
Following code, when compiled and run with g++, prints '1' twice, whereas I expect
The following code works great in IE, but not in FF or Safari. I
The following code doesn't compile with gcc, but does with Visual Studio: template <typename
The following code illustrates an object literal being assigned, but with no semicolon afterwards:

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.