Surely with that XAML you have a Warning shown in the Visual Studio Error List like the following?:
The resource "ExpandingImageStyle" could not be resolved.
This is telling you that your HierarchicalDataTemplate
can't find the Resource
. If you move that Style
to the top of your Window.Resources
, the first problem should disappear. However, when you do that, you'll then get a warning that the Style
can't find the two BitmapImage Resources
. So you'd better move those two Resources
to the top of your Window.Resources
:
<BitmapImage x:Key="Icon_Closed" UriSource="Images/Plus.ico"/>
<BitmapImage x:Key="Icon_Open" UriSource="Images/minus.ico"/>
<Style x:Key="ExpandingImageStyle" TargetType="{x:Type Image}">
...
</Style>
<XmlDataProvider x:Key="questions" XPath="Questions/Question" />
<HierarchicalDataTemplate x:Key="rootTemplate">
...
<Image Style="{StaticResource ExpandingImageStyle}" />
...
</HierarchicalDataTemplate>
If you find that that still doesn't work, please take a look at any errors or warnings that you may get in either the Error List
or Output Window
in Visual Studio and let us know.