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);
 }