Back to Main Load Limitations Page

""StaticResource"" references not resolved in Application.Resources


For example, in the example below the ""HighlightBrush"" will not be resolved at design time:

In Window1.xaml:
		 <Label Background="{StaticResource HighlightBrush}">StaticResource [MyApp] Resource</Label>
	

In myapp.xaml:

		 <Application.Resources>
		     [<SolidColorBrush] x:Key="HighlightBrush" Color="Yellow"/>
		 </Application.Resources>
	

Failure to resolve ""SolidColorBrush.Color"" for a string


The following does not work at design time:
		     [<SolidColorBrush] x:Key="BlueBrush">
		       [<SolidColorBrush.Color>]
		         Blue
		       [</SolidColorBrush.Color>]
		     [</SolidColorBrush>]
	

The following will work:
		     [<SolidColorBrush] x:Key="BlueBrush">
		       [<SolidColorBrush.Color>]
		         <Color>
		           Blue
		         </Color>
		       [</SolidColorBrush.Color>]
		     [</SolidColorBrush>]
	

as does the following:

		     [<SolidColorBrush] x:Key="GreenBrush">
		       [<SolidColorBrush.Color>]
		         <Color A="255" B="255" />
		       [</SolidColorBrush.Color>]
		     [</SolidColorBrush>]
	

		     [<SolidColorBrush] x:Key="YellowBrush" Color="Yellow" />
	

External ""ResourceDictionaries"" are not loaded at design time

		 [<ResourceDictionary] x:Key="ExternalResources" Source="ResourceDictionary.xaml"/>
	

or

		 [<ResourceDictionary] x:Key="ExternalResource" Source="C:\Src\ResourceDictionary.xaml"/> 
	

MergedDictionaries are not supported


		 [<ResourceDictionary.MergedDictionaries>]
	

Resources in a ""ResourceDictionary"" declaration inside of Window.Resources are not found by ""StaticResource""


For example, the Button should be Red however it is not unless the extra <ResourceDictionary> tag is removed, it will not be found:

		 <Window x:Class="TestAppBaseCS.Window1"
		         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
		         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
		         Title="Contacts"
		         Height="287"
		         Width="488"
		         >
		   <Window.Resources>
		     [<ResourceDictionary>]
		       [<SolidColorBrush] x:Key="Test"
		                        Color="Red"/>
		     [</ResourceDictionary>]
		   </Window.Resources>
		   <Grid>
		     <Button Background="{StaticResource Test}"/>
		   </Grid>
		 </Window>
	

As a workaround, ""DynamicResource"" can be used instead.

x:Shared is Not Supported


The following does not work in the designer regardless of the value of x:Shared:

		 <Window x:Class="TestAppBaseCS.Window1"
		         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
		         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
		         Title="Contacts"
		         Height="287"
		         Width="488"
		         >
		   <Window.Resources>
		     <Grid x:Shared="false"
		           x:Key="PopupGrid"
		           Opacity="1"
		           Margin="0,0,10,10" />
		     </Window.Resources>
		   <Grid>
		   </Grid>
		 </Window>
	

Multiple DataTemplates without an x:Key property fails in the designer


For example the following results in an error in the designer:

		 <Window 
		   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
		   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
		   x:Class="CiderWindowsApplication2.EmbeddedStoryboardExample"
		   xmlns:sys="clr-namespace:System;assembly=mscorlib" 
		   Title="Storyboard Example Embedded in an EventTrigger">
		   <Window.Resources>
		     [<DataTemplate] DataType="{x:Type sys:Int32}">
		       <Label>
		         <Rectangle/>
		       </Label>
		     [</DataTemplate>]
	

		     [<DataTemplate] DataType="{x:Type sys:Boolean}">
		       <Label>
		         <Rectangle/>
		       </Label>
		     [</DataTemplate>]
	

		     [<DataTemplate] DataType="{x:Type sys:Byte}">
		       <Label>
		         <Rectangle/>
		       </Label>
		     [</DataTemplate>]
		   </Window.Resources>
		   <Canvas Background="Ivory">
		     <Rectangle Width="100" Height="50" Fill="DodgerBlue" Margin="10">
		       <Rectangle.Triggers>
		       </Rectangle.Triggers>
		     </Rectangle>
		   </Canvas>
		 </Window>
	

Styles Are Applied to Panels at Design Time


For example:

The following should result in the panel being red, however it is not.

		   <Window.Resources>
		     <Style x:Key="NavigationPanelStyle" TargetType="{x:Type StackPanel}">
		       <Setter Property="Background" Value="Red"/>
		     </Style>
		   </Window.Resources>
		   <!--Panel should be Red-->
		   [<StackPanel] Style="{StaticResource NavigationPanelStyle}">
	

This is true for both DynamicResource and StaticResource

Open designers are not refreshed when external resources (Resource Dictionaries) are updated.

*Open designers are not automatically refreshed when external resource dictionaries ("Dictionary1.xaml") or the Application level resources ("MyApp.xaml") and are updated.
*Closing an open designer and re-opening it will resolve the problem.
*External resource dictionaries ("Dictionary1.xaml" or "MyApp.xaml") must to be saved before closing and opening the designer to see changes that result from the update.

For example:

""MyApp.xaml"" contains:
		 <Application x:Class="CiderWindowsApplication2.MyApp"
		    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
		    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
		    StartupUri="Window1.xaml"
		    >
		  <Application.Resources>
		    [<SolidColorBrush] x:Key="HighlightBrush" Color="Red"/>
		  </Application.Resources>
		 </Application>
	
""Window1.xaml"" contains:
		 <Window 
		  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
		  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
		  x:Class="CiderWindowsApplication2.Window1"
		  Title="Main Window">
		  <Grid>
		    <Label Background="{DynamicResource HighlightBrush}">My label</Label>
		  </Grid>
		 </Window>
	

* The developer opens the designer for Window1.xaml
* The label is displayed with a Blue background
* The developer goes to ""MyApp.xaml"" and changes Color to Red
* The developer goes back to the designer for Window1.xaml
* The label is still displayed with a Blue background
* The developer closes and opens the designer for Window1.xaml
* The label is now displayed with a Red background

Back to Main Load Limitations Page
Microsoft Communities