Note that there are some explanatory texts on larger screens.

plurals
  1. POStaticResource not found
    primarykey
    data
    text
    <p>I have the situation where a SolidColorBrush (defined in App.xaml) cannot be resolved during runtime, when i use the Brush in a Style as StaticResource.</p> <p>During designtime (using Visual Studio 2010) the brush is found, cause when i change the color of the brush the UIElement with the styles are updated with the new color.</p> <p>During runtime a XAMLParseException is raised, that the resource "color" cannot be found.</p> <p>Is this a normal behavior? I thought the resolving of StaticResource, starts from the UIElements up to the Application resources and that the Application resources are a good place to define default values (Colors, Fonts, etc.) for the UIElements of the Application.</p> <p><strong>App.xaml</strong></p> <pre><code>&lt;Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="SilverlightApplication1.App" &gt; &lt;Application.Resources&gt; &lt;ResourceDictionary&gt; &lt;SolidColorBrush Color="Green" x:Key="color"/&gt; &lt;ResourceDictionary.MergedDictionaries&gt; &lt;ResourceDictionary Source="Styles.xaml"/&gt; &lt;/ResourceDictionary.MergedDictionaries&gt; &lt;/ResourceDictionary&gt; &lt;/Application.Resources&gt; </code></pre> <p></p> <p><strong>Styles.xaml</strong></p> <pre><code>&lt;ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"&gt; &lt;Style TargetType="Border"&gt; &lt;Setter Property="BorderBrush" Value="{StaticResource color}" /&gt; &lt;Setter Property="BorderThickness" Value="1" /&gt; &lt;/Style&gt; </code></pre> <p></p> <p><strong>Main.xaml</strong></p> <pre><code>&lt;UserControl x:Class="SilverlightApplication1.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="400"&gt; &lt;Grid x:Name="LayoutRoot" Background="White"&gt; &lt;Border Height="100" HorizontalAlignment="Left" Margin="130,146,0,0" Name="border1" VerticalAlignment="Top" Width="200" /&gt; &lt;/Grid&gt; </code></pre> <p></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload