none
Replacing the +/- in a TreeView RRS feed

  • Question

  • Is there a good way to replace the +/- buttons on a TreeView?  HierarchicalDataTemplate doesn't seem to be the right choice, and I don't know how to use a ControlTemplate with a TreeView.

    Thanks

    Sunday, February 12, 2006 2:14 AM

Answers

  • Hi Jordan,

    Have you given Microsoft Expression Interactive Designer a shot at this (http://www.microsoft.com/expression)? Though we don't allow you to author HierarchicalDataTemplates in the tool, if you only wanted to change the template of a TreeViewItem, we do a good job at this.

    Thanks,
    Unni

    Sunday, February 12, 2006 4:02 AM

All replies

  • Hi Jordan,

    Have you given Microsoft Expression Interactive Designer a shot at this (http://www.microsoft.com/expression)? Though we don't allow you to author HierarchicalDataTemplates in the tool, if you only wanted to change the template of a TreeViewItem, we do a good job at this.

    Thanks,
    Unni

    Sunday, February 12, 2006 4:02 AM
  • You have to restyle the TreeViewItem if you want to replace the +/- button.
    Monday, February 13, 2006 2:22 AM
  • how could I restyle a treeviewItem?

     

    Friday, May 19, 2006 8:35 AM
  • Create a style and specify {x:Type TreeviewItem} for the TargetType.

    Once you've done this, call the style you've just created:

    <TreeviewItem Style={StaticResource NameOfYourTreeviewItemStyle} />


    HTH.

    Bye
    Friday, May 19, 2006 1:27 PM
  • Hi,

    Could you give an example? I think that I don´t know create an style.

     

     

    Thanks

     

    PD: I'm spanish and my english is very bad, I`m sorry

    Monday, May 22, 2006 7:16 AM
  • Hi

    Searching, I have found an example of styling a treeview.

    The example is here:

    ms-help://MS.MSSDK.1033/MS.WinFXSDK.1033/cpref26/html/P_System_Web_UI_WebControls_TreeView_CollapseImageUrl.htm

    But mi code is like this:

    <TreeView Style="{DynamicResource TreeViewStyle1}" Width="308" Height="249" Canvas.Left="2.8421709430404E-14" Canvas.Top="2.8421709430404E-14" x:Name="TreeView" RenderTransformOrigin="0.5,0.5">
       <TreeViewItem x:Name="TreeViewItem" RenderTransformOrigin="0.5,0.5" Header="TreeViewItem">
        <TreeViewItem x:Name="TreeViewItem2" RenderTransformOrigin="0.5,0.5" Header="TreeViewItem2"/>
        <TreeViewItem x:Name="TreeViewItem3" RenderTransformOrigin="0.5,0.5" Header="TreeViewItem3"/>
        <TreeViewItem x:Name="TreeViewItem4" RenderTransformOrigin="0.5,0.5" Header="TreeViewItem4"/>
       </TreeViewItem>

    ...........

    In this code I want to modify a treeview to change the image ("plus.jpg") of a collapse treeview, like in the example but I don´t know the way to do it.

    I need your help,

     

    Thanks

     

    Monday, May 22, 2006 10:07 AM
  • On this web page http://notstatic.com/simplestyles there is a good example of how to set up styles for many different controls.

    If you unzip the source code file on there you will find a file called TreeView.xaml that shows how to replace the Template of a TreeView

    Monday, May 22, 2006 1:45 PM
  • Thank you,

        That example give me a big idea to do the tree that I want to do.

        I have severals doubts and one is:

              what is the way to replace +/- by an image or icon

     

    thanks for all

     

    Tuesday, May 23, 2006 8:43 AM
  • I guess you put an image control in the treeview that loads from a resource:

      <!-- SimpleStyles: TreeViewItem -->
      <Style x:Key="ExpandCollapseToggleStyle" TargetType="{x:Type ToggleButton}">
        <Setter Property="Focusable" Value="False"/>
        <Setter Property="Template">
          <Setter.Value>
            <ControlTemplate TargetType="{x:Type ToggleButton}">
              <Grid
                Width="15"
                Height="13"
                Background="Transparent">
                <!-- Put Your Image Control Here -->
              </Grid>

    Tuesday, May 23, 2006 1:28 PM