Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. WCF and WF
  4. TreeView Binding Problem

TreeView Binding Problem

Scheduled Pinned Locked Moved WCF and WF
wpfwcfxmlhelpquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Kevin Marois
    wrote on last edited by
    #1

    I have a set of hierarchal data contained in classes that is loaded from a serialized XML file. Once deserialized, the objects have this format:

    Root
    |_ Groups
    |_Rules
    |_Conditions
    |_ Actions
    |_ Objects

    I have set up the necessesary HierarchicalDataTemplates for the Groups, Rules, and Conditions, and they show fine in the TreeView. I also set up a DataTemplate for the Actions and one for the Objects, but only Actions is showing. The reason is that because in the HierarchicalDataTemplate for the Condition the ItemSource is pointing to Actions:

    <!-- Condition -->
    <HierarchicalDataTemplate DataType="{x:Type local:RuleCondition}" ItemsSource="{Binding Path=Actions, Mode=TwoWay}">
    <StackPanel Orientation="Horizontal">
    <Image Source="/RulesEngineUI;component/Media/bluedot.png" Height="8" Width="8" Margin="0,0,3,0"/>
    <TextBlock Margin="0,0,5,0" FontWeight="Bold">Condition:</TextBlock>
    <TextBlock>
    <Hyperlink Name="Link" Style="{StaticResource LinkStyle}" Click="Link_Click">
    <TextBlock Text="{Binding Path=Operation}"></TextBlock>
    </Hyperlink>
    </TextBlock>
    </StackPanel>
    </HierarchicalDataTemplate>

    <!-- Action -->
    <DataTemplate DataType="{x:Type local:RuleAction}">
    <StackPanel Orientation="Horizontal">
    <TextBlock Margin="0,0,5,0" FontWeight="Bold">Action:</TextBlock>
    <TextBlock>
    <Hyperlink Name="Link" Style="{StaticResource LinkStyle}" Click="Link_Click">
    <TextBlock Text="{Binding Path=ActionField}"></TextBlock>
    </Hyperlink>
    </TextBlock>
    </StackPanel>
    </DataTemplate>

    <!-- Object -->
    <DataTemplate DataType="{x:Type local:RuleObject}">
    <StackPanel Orientation="Horizontal">
    <TextBlock Margin="0,0,5,0" FontWeight="Bold">Object:</TextBlock>
    <TextBlock>
    <Hyperlink Name="Link" Style="{StaticResource LinkStyle}" Click="Link_Click">
    <TextBlock Text="{Binding Path=Field}"></TextBlock>
    </Hyperlink>
    </TextBlock>
    </StackPanel>
    </DataTemplate>

    If you look at the Condtion HierarchicalDataTemplate you see that it refers to actions. How do I tell

    J 1 Reply Last reply
    0
    • K Kevin Marois

      I have a set of hierarchal data contained in classes that is loaded from a serialized XML file. Once deserialized, the objects have this format:

      Root
      |_ Groups
      |_Rules
      |_Conditions
      |_ Actions
      |_ Objects

      I have set up the necessesary HierarchicalDataTemplates for the Groups, Rules, and Conditions, and they show fine in the TreeView. I also set up a DataTemplate for the Actions and one for the Objects, but only Actions is showing. The reason is that because in the HierarchicalDataTemplate for the Condition the ItemSource is pointing to Actions:

      <!-- Condition -->
      <HierarchicalDataTemplate DataType="{x:Type local:RuleCondition}" ItemsSource="{Binding Path=Actions, Mode=TwoWay}">
      <StackPanel Orientation="Horizontal">
      <Image Source="/RulesEngineUI;component/Media/bluedot.png" Height="8" Width="8" Margin="0,0,3,0"/>
      <TextBlock Margin="0,0,5,0" FontWeight="Bold">Condition:</TextBlock>
      <TextBlock>
      <Hyperlink Name="Link" Style="{StaticResource LinkStyle}" Click="Link_Click">
      <TextBlock Text="{Binding Path=Operation}"></TextBlock>
      </Hyperlink>
      </TextBlock>
      </StackPanel>
      </HierarchicalDataTemplate>

      <!-- Action -->
      <DataTemplate DataType="{x:Type local:RuleAction}">
      <StackPanel Orientation="Horizontal">
      <TextBlock Margin="0,0,5,0" FontWeight="Bold">Action:</TextBlock>
      <TextBlock>
      <Hyperlink Name="Link" Style="{StaticResource LinkStyle}" Click="Link_Click">
      <TextBlock Text="{Binding Path=ActionField}"></TextBlock>
      </Hyperlink>
      </TextBlock>
      </StackPanel>
      </DataTemplate>

      <!-- Object -->
      <DataTemplate DataType="{x:Type local:RuleObject}">
      <StackPanel Orientation="Horizontal">
      <TextBlock Margin="0,0,5,0" FontWeight="Bold">Object:</TextBlock>
      <TextBlock>
      <Hyperlink Name="Link" Style="{StaticResource LinkStyle}" Click="Link_Click">
      <TextBlock Text="{Binding Path=Field}"></TextBlock>
      </Hyperlink>
      </TextBlock>
      </StackPanel>
      </DataTemplate>

      If you look at the Condtion HierarchicalDataTemplate you see that it refers to actions. How do I tell

      J Offline
      J Offline
      Jurgen Rohr
      wrote on last edited by
      #2

      Hi, from your structure I assume your intention is to have several Action/Object-pairs under each condition and to accomplish that, you created two lists of identical length: one of Objects and one of Actions. You should replace the two lists with one list of a combined class like:

      public class CombinedClass
      {
      public RuleObject { get; set; }
      public RuleAction { get; set; }
      }

      Then it should be almost self-solving!? But maybe, I got your structure wrong. Cheers Jürgen

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups