admin管理员组

文章数量:1122832

I'm quite new to wpf and I have a desktop project where several applications are running at the same time on different PCs. Some of the screens are the same in the different applications. As we do with the backend (the common code is in several class libraries), I would like to do the same for the frontend. I created a WPF class library and inside, I moved all the resources, some need code for communicating with backhand and I tried to move some usercontrols (WPF) to reuse them in the different applications. My problem is, when I try to use the usercontrol moved into the lib, the app cannot find the viewModel file (when the usercontrol is added directly in the WPF) or the view file (when I use a contentControl). I'm using the caliburn.micro framework, for all apps 6.0 framework and I'm using the standard naming conventions in the lib and all the frontend apps.

What should I do to move/create usercontrols in a WpF class library and use them in my projects?

I tried to rewrite usercontrols moved to lib to no longer use caliburn.micro (only in WPF calss library) I tried to instantiate viewModel and assign to the dataContext of the corresponding view added directly as an object in my WPF. In the Bootstrapper I have added/changed:

protected override IEnumerable<Assembly> SelectAssemblies()
{
    return AppDomain.CurrentDomain.GetAssemblies().ToArray();
}
ViewLocator.AddSubNamespaceMapping("abcd.WPFLib.*.ViewModels","abcd.WPFLib.*.Views");

Thanks

本文标签: wpf controlsUse create a WPF Class LibraryStack Overflow