code_junkie

Creating a XAML Resource from Code Without a Key

Nov 11th, 2011
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. <TreeView.Resources>
  2. <HierarchicalDataTemplate DataType="{x:Type xbap:FieldPropertyInfo}"
  3. ItemsSource="{Binding Path=Value.Values}">
  4. <TextBlock Text="{Binding Path=Name}" />
  5. <HierarchicalDataTemplate>
  6. </TreeView.Resources>
  7.  
  8. HierarchicalDataTemplate fieldPropertyTemplate = new HierarchicalDataTemplate("FieldProperyInfo");
  9.  
  10. fieldPropertyTemplate.ItemsSource = new Binding("Value.Values");
  11.  
  12. this.Resources.Add(null, fieldPropertyTemplate);
  13.  
  14. HierarchicalDataTemplate fieldPropertyTemplate = new
  15. HierarchicalDataTemplate("FieldProperyInfo");
  16.  
  17. fieldPropertyTemplate.SetBinding(
  18. HierarchialDataTemplate.ItemSourceProperty,
  19. new Binding("Value.Values");
  20. this.Resources.Add(FieldPropertyInfo.GetType(), fieldPropertyTemplate);
  21.  
  22. this.Resources.Add(FieldPropertyInfo.GetType(), fieldPropertyTemplate);
Add Comment
Please, Sign In to add comment