http://www.cnblogs.com/ListenFly/archive/2013/03/13/2953096.html
<Image Source="1.jpg" />
<Image Source="pack://application:,,,/1.jpg"/>
<Image Source="/smmc;component/Images/undo_16.png" ></Image>
<Image Source="Images/1.jpg"></Image>
<Image Source="/Images/2.jpg" Grid.Row="1"></Image>
Uri uri = new Uri("/siteoforiginfile.xaml", UriKind.Relative);
StreamResourceInfo info = Application.GetRemoteStream(uri);
System.Windows.Markup.XamlReader reader = new System.Windows.Markup.XamlReader();
Page page = (Page)reader.LoadAsync(info.Stream);
this.siteoforiginfileframe.Content = page;
void click0(object sender, RoutedEventArgs e) {
Uri uri = new Uri("/VersionedReferencedAssembly;v1.0.0.0;component/ResourceFile.xaml", UriKind.RelativeOrAbsolute);
this.frame.Source = uri;
}
void click1(object sender, RoutedEventArgs e)
{
Uri uri = new Uri("/VersionedReferencedAssembly;v1.0.0.1;component/ResourceFile.xaml", UriKind.RelativeOrAbsolute);
this.frame.Source = uri;
}
=========================================================================
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Styles/DefaultStyle.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
============================================================
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="DefaultStyle/Button.xaml"/>
</ResourceDictionary.MergedDictionaries>
<Style TargetType="{x:Type Rectangle}" />
</ResourceDictionary>
======================================================================
<ResourceDictionary.MergedDictionaries>
<SharedResourceDictionary Source="/MyControlLibrary;component/Themes/Brushes.xaml" />
</ResourceDictionary.MergedDictionaries>
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
public class SharedResourceDictionary : ResourceDictionary
{
/// <summary>
/// Internal cache of loaded dictionaries
/// </summary>
public static Dictionary<Uri, ResourceDictionary> _sharedDictionaries =
new Dictionary<Uri, ResourceDictionary>();
/// <summary>
/// Local member of the source uri
/// </summary>
private Uri _sourceUri;
/// <summary>
/// Gets or sets the uniform resource identifier (URI) to load resources from.
/// </summary>
public new Uri Source
{
get { return _sourceUri; }
set
{
_sourceUri = value;
if (!_sharedDictionaries.ContainsKey(value))
{
// If the dictionary is not yet loaded, load it by setting
// the source of the base class
base.Source = value;
// add it to the cache
_sharedDictionaries.Add(value, this);
}
else
{
// If the dictionary is already loaded, get it from the cache
MergedDictionaries.Add(_sharedDictionaries[value]);
}
}
}
}