WPF Hierarchical Data Templates are killing me
-
Ok, I've defined a simple class called NonDataNode that has two members, Name (string) and ContainedItems (object) which will hold whatever type of object is contained by that node in the tree (couldn't be more specific because it could be just about anything). I also created another class called NonDataNodeList, which inherits from List. There are no changes in implementation, I just wanted a name that was easier to work with in XAML. ImageOutputType is a business object in my application. lib and local are namespaces defined with xmlns elements at the top of the XAML. The Window.Resources section is before the tree control. So, the XAML for my treeview looks like this: In my Window.Resources section, I've defined the following: You can see that the key for the heirarchical data template is NonDataNodeTemplate and that the treeview uses that as the item template. However, when I try to run this thing, I get the following error: Cannot find resource named '{NonDataNodeTemplate}'. Resource names are case sensitive. Error at object 'trvNavigate' in markup file 'WGAdminPanel;component/mainwindow.xaml' Line 76 Position 82. Now, I'm sure it's something simple I'm missing, but I've been stuck on this for about 4 hours. Can someone help me? I've tried google, but so far I haven't found any examples that I can make work. Thanks, Will
-
Ok, I've defined a simple class called NonDataNode that has two members, Name (string) and ContainedItems (object) which will hold whatever type of object is contained by that node in the tree (couldn't be more specific because it could be just about anything). I also created another class called NonDataNodeList, which inherits from List. There are no changes in implementation, I just wanted a name that was easier to work with in XAML. ImageOutputType is a business object in my application. lib and local are namespaces defined with xmlns elements at the top of the XAML. The Window.Resources section is before the tree control. So, the XAML for my treeview looks like this: In my Window.Resources section, I've defined the following: You can see that the key for the heirarchical data template is NonDataNodeTemplate and that the treeview uses that as the item template. However, when I try to run this thing, I get the following error: Cannot find resource named '{NonDataNodeTemplate}'. Resource names are case sensitive. Error at object 'trvNavigate' in markup file 'WGAdminPanel;component/mainwindow.xaml' Line 76 Position 82. Now, I'm sure it's something simple I'm missing, but I've been stuck on this for about 4 hours. Can someone help me? I've tried google, but so far I haven't found any examples that I can make work. Thanks, Will
-
what happens if you try this: DataType="{x:Type local:NonDataNode}" instead of DataType="local:NonDataNode" ? Mihai,