private void InitializeComponent() { ResourceLoader.ResourceLoadingQuery resourceLoadingQuery = new ResourceLoader.ResourceLoadingQuery(); resourceLoadingQuery.set_AssemblyName(typeof(FormsApp).GetTypeInfo().Assembly.GetName()); resourceLoadingQuery.set_ResourcePath("FormsApp.xaml"); resourceLoadingQuery.set_Instance((object)this); if (ResourceLoader.CanProvideContentFor(resourceLoadingQuery)) { this.__InitComponentRuntime(); } else if (XamlLoader.get_XamlFileProvider() != null && XamlLoader.get_XamlFileProvider()(((object)this).GetType()) != null) { this.__InitComponentRuntime(); } else { ResourceDictionary resourceDictionary1 = new ResourceDictionary(); FormsApp formsApp; NameScope nameScope = (NameScope)(NameScope.GetNameScope((BindableObject)(formsApp = this)) ?? (INameScope) new NameScope()); NameScope.SetNameScope((BindableObject)formsApp, (INameScope)nameScope); ((Application)formsApp).set_Resources(resourceDictionary1); ResourceDictionary resourceDictionary2 = resourceDictionary1; Uri uri1; resourceDictionary1.SetAndLoadSource(uri1 = new Uri("Styles.xaml", UriKind.RelativeOrAbsolute), "Styles.xaml", typeof(FormsApp).GetTypeInfo().Assembly, (IXmlLineInfo) new XmlLineInfo(9, 29)); Uri uri2 = uri1; resourceDictionary2.set_Source(uri2); ((Application)formsApp).set_Resources(resourceDictionary1); } }
public void ChangeTheme(bool highContrast) { var themeUri = "ThemeResources/" + (highContrast ? "HighContrastTheme" : "DefaultTheme") + ".xaml"; var source = new Uri(themeUri, UriKind.Relative); ResourceDictionary.SetAndLoadSource(source, themeUri, this.GetType().GetTypeInfo().Assembly, null); }
public void SetAndLoadSourceTest2() { tlog.Debug(tag, $"SetAndLoadSourceTest2 START"); ResourceDictionary t1 = new ResourceDictionary(); Assert.IsNotNull(t1, "null ResourceDictionary"); ResourceDictionary t2 = new ResourceDictionary(); Assert.IsNotNull(t2, "null ResourceDictionary"); t1.MergedWith = typeof(ResourceDictionary); Assert.Throws <ArgumentException>(() => t1.SetAndLoadSource(new Uri("http://www.contoso.com/"), "X", typeof(View).Assembly, null)); tlog.Debug(tag, $"SetAndLoadSourceTest2 END"); }
public void SetAndLoadSourceTest() { tlog.Debug(tag, $"SetAndLoadSourceTest START"); try { ResourceDictionary t1 = new ResourceDictionary(); Assert.IsNotNull(t1, "null ResourceDictionary"); t1.SetAndLoadSource(new Uri("http://www.contoso.com/"), "layout/MyResourceDictionary.xaml", typeof(UIElement).Assembly, null); Assert.True(true, "Should go here"); } catch (Exception e) { Assert.Fail("Caught Exception" + e.ToString()); } tlog.Debug(tag, $"SetAndLoadSourceTest END"); }