Пример #1
0
        private static void LoadComponent(FrameworkElement fe, string componentId, bool selfCall = false)
        {
            // Don't load component in design mode
            var isDesignMode = (bool)DesignerProperties.IsInDesignModeProperty.GetMetadata(typeof(DependencyObject)).DefaultValue;

            if (Application.Current == null || isDesignMode)
            {
                return;
            }

            //if (_isInitializing && !selfCall) {
            //    InitializationQueue.Enqueue(Tuple.Create(fe, componentId));
            //    return;
            //}

            //_isInitializing = true;

            var split            = componentId.Split(',');
            var resourceAssembly = Assembly.GetEntryAssembly();

            if (resourceAssembly == null)
            {
                return;
            }

            foreach (var value in split)
            {
                try {
                    var buffer = RuntimeUpdateHandler.FindBuffer(value);
                    if (buffer != null)
                    {
                        XamlHelper.InitializeComponent(fe, buffer, new Uri(value, UriKind.Relative));
                    }
                    else
                    {
                        XamlHelper.InitializeComponent(fe, value);
                    }
                } catch (Exception e) {
                    Debug.WriteLine("Failed to initialize with: " + value);
                    Debug.WriteLine(e.Message);
                }
            }

            //ProcessQueue();

            //_isInitializing = false;
        }
Пример #2
0
        private static void LoadComponent(Element fe, string componentId, bool selfCall = false)
        {
            var split = componentId.Split(',');

            foreach (var value in split)
            {
                try {
                    var buffer = RuntimeUpdateHandler.FindBuffer(value);
                    if (buffer != null)
                    {
                        RuntimeUpdateHandler.InitializeComponent((View)fe, buffer);
                    }
                    else
                    {
                        fe.LoadFromXaml(fe.GetType());
                    }
                } catch (Exception e) {
                    Debug.WriteLine("Failed to initialize with: " + value);
                    Debug.WriteLine(e.Message);
                }
            }
        }