CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    May 2009
    Posts
    2

    Red face ResourceDictionary reference error

    I created the following resource dictionary, but the reference to ItemFontStyle throws a reference error ("StaticResource reference 'ItemFontStyle' was not found") in the HierarchicalDataTemplate. Any suggestions?

    <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <Style x:Key="ItemFontStyle">
    <Setter Property="Control.Foreground" Value="Black" />
    <Style.Triggers>
    <DataTrigger Binding="{Binding Path=Discontinued}" Value="True">
    <Setter Property="Control.Foreground" Value="Gray" />
    <Setter Property="Control.FontStyle" Value="Italic" />
    </DataTrigger>
    </Style.Triggers>
    </Style>

    <HierarchicalDataTemplate x:Key="ItemTemplate">
    <Grid>
    <Grid.ColumnDefinitions>
    <ColumnDefinition></ColumnDefinition>
    <ColumnDefinition></ColumnDefinition>
    </Grid.ColumnDefinitions>
    <TextBlock Grid.Column="0" Text="{Binding Path=name}" Padding="2" Width="200"
    Style="{StaticResource ItemFontStyle}" />
    <TextBlock Grid.Column="1" Text="{Binding Path=UnitsInStock}" Padding="2"
    Style="{StaticResource ItemFontStyle}" />
    </Grid>
    </HierarchicalDataTemplate>

    </ResourceDictionary>

  2. #2
    Join Date
    May 2009
    Posts
    2

    Re: ResourceDictionary reference error

    Please ignore this question - I'm even redder in my face - when the xaml was closed and then reopened ... the erro disappeared.

    This is reminiscent of Windows 3.1 - close the window, open the window - ;-}

    Thanks

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured