LoadComponent() 공개 정적인 메소드

public static LoadComponent ( object component, Uri resourceLocator ) : void
component object
resourceLocator Uri
리턴 void
예제 #1
0
 public void InitializeComponent()
 {
     if (_contentLoaded)
     {
         return;
     }
     _contentLoaded = true;
     Application.LoadComponent(this, new Uri("/Manager;component/editpicturecontrol.xaml", UriKind.Relative));
 }
예제 #2
0
 public static bool AddCustomStyles(this Window window, string styleResourceFile)
 {
     try
     {
         var res = (ResourceDictionary)Application.LoadComponent(new Uri(styleResourceFile, UriKind.Relative));
         if (res != null)
         {
             window.Resources.MergedDictionaries.Add(res);
         }
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
예제 #3
0
        /// <summary>
        /// 设置程序显示语言
        /// </summary>
        /// <param name="languageTag">程序中已包含的语言字典名称,例如zh-CN</param>
        //设置语言
        public static void SetLanguage(string languageTag)
        {
            List <ResourceDictionary> dictionaryList = new List <ResourceDictionary>();

            foreach (ResourceDictionary dictionary in Application.Current.Resources.MergedDictionaries)
            {
                dictionaryList.Add(dictionary);
            }

            string requestedCulture = string.Format(@"Language\{0}.xaml", languageTag);

            Uri reUri = new Uri(requestedCulture, UriKind.Relative);
            ResourceDictionary rdDictionary = (ResourceDictionary)Application.LoadComponent(reUri);

            Application.Current.Resources.MergedDictionaries.Remove(rdDictionary);
            Application.Current.Resources.MergedDictionaries.Add(rdDictionary);
        }
예제 #4
0
        public VisualBrush LoadIcon(string path, string resourceKey)
        {
            Object obj = Application.Current.TryFindResource(resourceKey);

            if (obj == null)
            {
                Object comp = Application.LoadComponent(
                    new Uri(path + resourceKey + ".xaml", UriKind.Relative));

                Application.Current.Resources.MergedDictionaries.Add(comp as ResourceDictionary);

                var brush = (VisualBrush)Application.Current.FindResource(resourceKey);

                return(brush);
            }
            else
            {
                return((VisualBrush)obj);
            }
        }
예제 #5
0
        private void AddResourceDictionary(string source)
        {
            var resourceDictionary = Application.LoadComponent(new Uri(source, UriKind.Relative)) as ResourceDictionary;

            Resources.MergedDictionaries.Add(resourceDictionary);
        }
예제 #6
0
 private static ResourceDictionary LoadResourceDictionary(string source)
 {
     return(Application.LoadComponent(source) as ResourceDictionary);
 }