question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using Caliburn Micro in class library

See original GitHub issue

I have a class library which contains several user controls. This library uses caliburn micro to bind the UserControls to their corresponding ViewModels using x:Name approach in the same class library.

Now I have an host application which hosts these UserControls in a Window. But this host application doesn’t use Caliburn Micro at all. Then how can I initialize caliburn bootstrapper in the library itself.

HostApplication:

<Window>       
  <ContentControl>
       <library:MainUserControl DataContext="{Binding MainUserControlViewModel}"/>
  </ContentControl>
</Window>

Class Library

<UserControl x:Class="MainUserControl">
       <ContentControl x:Name="OtherUserControlInSameLibrary"/>
</UserControl>

I tried to inherit Bootstrapper base class like AppBootstrapper: Bootstrapperbase and passing false to constructor parameter useApplication. And then I called Initialize() method. But still conventions are not applied.

MainUserControlViewModel Constructor

public MainUserControlViewModel()
{             
     AppBootstrapper appBootstrapper = new AppBootstrapper();
     appBootstrapper.Initialize();
     if (Debugger.IsAttached)
            LogManager.GetLog = type => new DebugLog(type);            
}

BootstrapperBase override

 public class AppBootstrapper : BootstrapperBase
    {
        public AppBootstrapper():base(false)
        {
        }
    }

I also tried to run caliburn debugger but nothing is showed in my output window.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
tanaililingcommented, Oct 8, 2018

I have a class library which contains several user controls. This library uses caliburn micro to bind the UserControls to their corresponding ViewModels using x:Name approach in the same class library.

Now I have an host application which hosts these UserControls in a Window. But this host application doesn’t use Caliburn Micro at all. Then how can I initialize caliburn bootstrapper in the library itself.

HostApplication:

<Window>       
  <ContentControl>
       <library:MainUserControl DataContext="{Binding MainUserControlViewModel}"/>
  </ContentControl>
</Window>

Class Library

<UserControl x:Class="MainUserControl">
       <ContentControl x:Name="OtherUserControlInSameLibrary"/>
</UserControl>

I tried to inherit Bootstrapper base class like AppBootstrapper: Bootstrapperbase and passing false to constructor parameter useApplication. And then I called Initialize() method. But still conventions are not applied.

MainUserControlViewModel Constructor

public MainUserControlViewModel()
{             
     AppBootstrapper appBootstrapper = new AppBootstrapper();
     appBootstrapper.Initialize();
     if (Debugger.IsAttached)
            LogManager.GetLog = type => new DebugLog(type);            
}

BootstrapperBase override

 public class AppBootstrapper : BootstrapperBase
    {
        public AppBootstrapper():base(false)
        {
        }
    }

I also tried to run caliburn debugger but nothing is showed in my output window.

hello , Is Resolved your question ?Using Caliburn Micro in class library

0reactions
ottossoncommented, Jan 18, 2021

I’m as well in pursuit of building a class library using CM. In my case I build Revit add-ins which is loaded from a dll. Is it at all possible? I can use some parts of CM, but others like ActivateItem does not work out of the box.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using Caliburn Micro in class library
This library uses caliburn micro to bind the UserControl s to their corresponding ViewModels using x:Name approach in the same class library.
Read more >
Caliburn.Micro · 'Xaml made easy' · Caliburn.Micro
A small, yet powerful framework, designed for building applications across all XAML platforms (.NET 4.5+ and .NET Core 3.0+). Its strong support for...
Read more >
MVVM framework that works in a class library project.
Caliburn Micro makes MVVM look like magic and has a very simple convention to be followed to make it all work. This is...
Read more >
Simple IoC Container
Micro comes pre-bundled with a Dependency Injection container called SimpleContainer. For those unfamiliar, a dependency injection container is an object ...
Read more >
Simplifying MVVM and Caliburn.Micro
Use the method in the Caliburn. Micro class in order to capture the event when a property is changed. Now, we can go...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found