Useful Tip: Solution for known issue with Merged Dictionaries in App.xaml (VS 2010 RTM)

23 באפריל 2010

At last days many .Net developers upgraded their Visual Studio to RTM 2010. There are some “Known Issues” in this release.After painful upgrade we discovered problem in our WPF project: Some Dynamic Resources from Merged Dictionaries that referenced in App.xaml stopped working (although this code worked without any problems in Beta-2).We found some workaround: Add some style without specific key for unused element in Resource Dictionary and this will trigger WPF to load resources from Merged Dictionaries. Example: <Application x:Class="SomeNamespace.App"              xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">       <Application.Resources>             <ResourceDictionary>                   <ResourceDictionary.MergedDictionaries>                         <ResourceDictionary Source="/SomeNamespace;Component/Styles.xaml"/>                         <ResourceDictionary Source="/SomeNamespace;Component/Brushes.xaml"/>                   </ResourceDictionary.MergedDictionaries>                                 <Style TargetType="{x:Type Line}"/>...