protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            VisualComposition.Trace += (sender, args) => Trace.WriteLine(args.Text);
            BindingErrorTracer.Start(BindingErrorCallback);

            var context = new RegistrationBuilder();

            // Visuals can't be singletons:
            context.ForTypesDerivedFrom <FrameworkElement>()?.SetCreationPolicy(CreationPolicy.NonShared);
            // To demonstrate the ImportExtension with value converters.
            context.ForTypesDerivedFrom <IValueConverter>()?.Export();
            try
            {
                _compositionHost.AddCatalog(new ApplicationCatalog(context));
            }
            catch (ReflectionTypeLoadException ex)
            {
                MessageBox.Show(ex.Message + "\n" + string.Join("\n", ex.LoaderExceptions.Select(le => le.Message)));
            }


            Resources.MergedDictionaries.Insert(0, WpfStyles.GetDefaultStyles().RegisterDefaultWindowStyle());
            Resources.MergedDictionaries.Add(DataTemplateManager.CreateDynamicDataTemplates(_compositionHost.Container));

            MainWindow = _compositionHost.GetExportedValue <MainWindow>();
            MainWindow.Show();
        }
Beispiel #2
0
        /// <summary>
        /// Standard constructor for the tool window.
        /// </summary>
        public ToolWindow()
            : base(null)
        {
            // Just to reference something to force load of referenced libraries.
            BindingErrorTracer.Start(msg => { Debug.WriteLine(msg); });

            Caption = Properties.Resources.ToolWindowTitle;

            BitmapResourceID = 301;
            BitmapIndex      = 1;
        }
Beispiel #3
0
        protected override void OnStartup([CanBeNull] StartupEventArgs e)
        {
            base.OnStartup(e);

            VisualComposition.Trace += (sender, args) => Trace.WriteLine(args.Text);
            BindingErrorTracer.Start(BindingErrorCallback);

            _diAdapter = new DIAdapter();

            var exportProvider = _diAdapter.Initialize();

            Resources.MergedDictionaries.Insert(0, WpfStyles.GetDefaultStyles().RegisterDefaultWindowStyle());
            Resources.MergedDictionaries.Add(DataTemplateManager.CreateDynamicDataTemplates(exportProvider));

            var mainWindow = exportProvider.GetExportedValue <MainWindow>();

            MainWindow = mainWindow;

            mainWindow.Show();
        }
Beispiel #4
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            BindingErrorTracer.Start(BindingErrorCallback);

            var context = new RegistrationBuilder();

            // Visuals can't be singletons:
            context.ForTypesDerivedFrom <FrameworkElement>()?.SetCreationPolicy(CreationPolicy.NonShared);
            // To demonstrate the ImportExtension with value converters.
            context.ForTypesDerivedFrom <IValueConverter>()?.Export();
            _compositionHost.AddCatalog(new ApplicationCatalog(context));

            var dataTemplateResources = DataTemplateManager.CreateDynamicDataTemplates(_compositionHost.Container);

            Resources.MergedDictionaries.Add(dataTemplateResources);

            Resources.MergedDictionaries.Insert(0, WpfStyles.Defaults());

            MainWindow = _compositionHost.GetExportedValue <MainWindow>();
            MainWindow.Show();
        }