Anything defined inside ResourceDictionary must be available as static resource

My VS has some issued which was driving me crazy. I declared a resource (an object) in a resource dictionary and gave it a key. This resource dictionary was external and was referenced via MergedDictionaries. When i tried referencing that resource via its key, I was getting compile time error saying resource not found. This could lead to a lot of confusion for beginners. Please note that whether you define the resource inline, or at parent container(i.e grid/stackpanel etc) or at usercontrol/windows level or even at Application level, it must be available to be referenced in a consistent manner irrespective of its scope and definition


<Window x:Class="WpfApplication1.MainWindow"
 Title="MainWindow" Height="677" Width="686.194">
 <Grid x:Name="Grid">
 <ResourceDictionary Source="Dictionary1.xaml"></ResourceDictionary>

 <ListBox Name="ItemsControl" ItemsSource="{Binding ElementName=Window, Path=Collection}" ItemTemplateSelector="{StaticResource ViewTemplateSelector}" Margin="0,0,328,0"/>
 <Button Content="Open View One" HorizontalAlignment="Left" Margin="450,73,0,0" VerticalAlignment="Top" Width="95" Click="Button_Click"/>
 <Button Content="Open View Two" HorizontalAlignment="Left" Margin="450,145,0,0" VerticalAlignment="Top" Width="95" Click="Button_Click_1"/>


The above code refereneces a ViewTemplateSelector resource which is defined in an external dictionary called Dictionary1.xaml. Now even if this resource is moved to App.xaml or inline within the window itself, i shouldn’t need to have to change my {StaticResource ViewTemplateSelector} markup at all

I sorted the bug in my VS but I thought if the same happens to a novice WPF learner the it might change his fundamental understanding on how resources are referenced.