silverlight - StaticResource not found -


I have a situation where a solid coilbrush (defined in App.xaml) can not be resolved during runtime, When I use Brush Static Resource as a Style.

The brush is found during design time (using Visual Studio 2010), so when I change the color of the brush, UIElement is updated with the new color along with the styles.

An XAMLParseException is raised during the runtime, that the resource "color" is not found.

Is this a normal behavior? I thought the solution of static resources starts up from UIElements to application resources and that application resource is a good place to define default values ​​(color, font etc.) for UIIlames.

App.xaml

  & lt; Application xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns: x = "http://schemas.microsoft.com/winfx/2006/xaml" x: class = "silverlight application 1. App "& gt; & Lt; Application.Resources & gt; & Lt; ResourceDictionary & gt; & Lt; Solid color brush color = "green" x: key = "color" /> & Lt; ResourceDictionary.MergedDictionaries & gt; & Lt; Source Source = "Styles.Xml" /> & Lt; /ResourceDictionary.MergedDocs> & Lt; / ResourceDictionary & gt; & Lt; /Application.Resources>  

Styles.xaml

  & lt; Resource Tools xmlns = "http: // schema 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 = "{color of static resources}" /> & Lt; Setter property = "borderline" value = "1" /> & Lt; / Style & gt;  

main.xaml

  & 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: /sschemas.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 = "Layouts" background = "White" & gt; & Lt; Border height = "100" horizontal alignment = "left" margin = "130,146,0,0" name = "border1" workspaceElement = "top" width = "200" /> & Lt; / Grid & gt;       

I resume processing definitions : Apply and SolidColorBrush to "Color" in a ResourceDictionary "General.xaml"

I added ResourceDictionary "General.xaml" to ResourceDictionary "Styles.xaml". Now it works without problems. I think this is a way to go with the resources.

General.xaml

  & lt; Resource area xmlns = "http: // schemas Microsoft.com/winfx/2006/xaml/presentation" xmlns: x = "http://schemas.microsoft.com/winfx/2006/xaml" & gt; & Lt; Solid color brush color = "green" x: key = "color" /> & Lt; / ResourceDictionary & gt;  

Styles. Xml

  & lt; Processing Zone xmlns = "http://schemas.microsoft.com/winfx/2006/Xaml/Presentation" xmlns: x = "http://schemas.microsoft.com/winfx/2006/xaml" & gt; & Lt; ResourceDictionary.MergedDictionaries & gt; & Lt; Source Source = "General .xml" /> & Lt; /ResourceDictionary.MergedDocs> & Lt; Style TargetType = "border" & gt; & Lt; Setter property = "borderbrush" value = "{color of static resources}" /> & Lt; Setter property = "borderline" value = "1" /> & Lt; / Style & gt; & Lt; / ResourceDictionary & gt;  

Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -