I have a data template for my listbox and I must use project resources for all the labels. If I remove the reference to the resource and just type in the text for the labels there are no errors. If I try to use the resources I get the above error.
Here is the data template:
<DataTemplate x:Key="CheckBoxDatePickerItemTemplate">
<Border BorderThickness="1" CornerRadius="3" BorderBrush="{StaticResource GreenBorderBrush}">
<StackPanel Orientation="Horizontal" Background="#208897EB" MinWidth="370">
<CheckBox Focusable="False" IsChecked="{Binding IsChecked}" VerticalAlignment="Top"/>
<ContentPresenter Content="{Binding Name, Mode=OneTime}" Margin="2,2" Width="140" VerticalAlignment="Top"/>
<StackPanel Orientation="Vertical" Visibility="{Binding DateDataVisible}">
<StackPanel Orientation="Horizontal">
<CheckBox IsChecked="{Binding IncludeNullDates}" VerticalAlignment="Center" Focusable="False"/>
<Label Content="{x:Static resx:Resources.Label_IncludeEmptyDates}" Margin="2,2" Width="170" VerticalAlignment="Center"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<ContentPresenter Content="{x:Static resx:Resources.Label_From}" Margin="2,0" Width="50" VerticalAlignment="Center"/>
<DatePicker SelectedDate="{Binding StartDate}" Margin="2,2" Width="150" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<ContentPresenter Content="{x:Static resx:Resources.Label_To}" Margin="2,0" Width="50" VerticalAlignment="Center"/>
<DatePicker SelectedDate="{Binding EndDate}" Margin="2,2" Width="150" />
</StackPanel>
</StackPanel>
</StackPanel>
</Border>
</DataTemplate>
One thing to note we are using the resources in other XAML files with no problems. This file however is a resource dictionary and is added to the app.xaml resources. What’s with this error?
We are working on this project in a team and I just copied the line for using resources… I just forgot to copy the xmlns attribute as well. What I find strange is that the error isn’t really descriptive and doesn’t give any real hints as to what the problem is.
Moral of the story: if copying lines of code make sure that all references to namespaces are also copied.