I want to use an external file to customize the styles in my application, but it does not work. I follow this step by step , but when I execute the project exception, it falls into:
In System.Windows.ni.dll
The first random error like "System.Windows.Markup.XamlParseException" occurred
My XAML code:
App.xaml:
<Application.Resources> <local:LocalizedStrings xmlns:local="clr-namespace:App1" x:Key="LocalizedStrings"/> <ResourceDictionary x:Key="myDict"> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="Resources.xaml"/> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </Application.Resources>
Resources.xaml:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <Style TargetType="TextBox" x:Key="MyTextBox"> <Setter Property="Background" Value="Transparent"/> <Setter Property="BorderThickness" Value="0.5"/> <Setter Property="BorderBrush" Value="Gray"/> <Setter Property="Opacity" Value="0.5"/> <Setter Property="Foreground" Value="Red"/> </Style> </ResourceDictionary>
source share