By adding manually,,,, I ment that I added assemlys to mef in code behind,, like the examples given. Your apporach using xaml looked more "automatic" to me :)
At the moment my application is working but I am not qute sure why :)
First of all, I done i automatic ;),,,, I have rewritten it so that assemblys are added in XAML. This mean that the following line:
var presenter = _container.GetExportedObject<IPersonCollectionPresenter>();
is changed to: (no strange whit this)
var provider = Application.Current.GetApplicationExportProvider();
var presenter = provider.GetExportedObject<IPersonCollectionPresenter>();
presenter is a PersonCollectionPresenter and looks like:
public class PersonPresenter : PresenterBase, IPersonCollectionPresenter
public PersonPresenter(IPersonCollectionView _collection)
IPersonCollectionView is a UserControl and contains the xaml code I've showed you before (contains PersonCrudTemplate etc). The c# code looks like ...
public partial class PersonCollectionView : UserControl, IPersonCollectionView
InitializeComponent indicates that there are some problems. Just doing like your example gives a Exception from this function. I've not been able to trace it, so I dont understand why. This exception only occures when
mef:Composition.Compose="True" is set for the
AddToListBoxControl as show above.
If I adds
mef:Composition.Compose="True" to the PersonCollectionView the exeption disappers.....
(just to be clear)
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:Converters="clr-namespace:lgTronic.ActiveWork.Infrastructure.Converters;assembly=lgTronic.ActiveWork.Infrastructure" xmlns:Validation="clr-namespace:lgTronic.ActiveWork.Infrastructure.Validation;assembly=lgTronic.ActiveWork.Infrastructure"
Loaded="UserControl_Loaded" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
So,,, the key for me was to add mef:Composition.Compose="True" to
the "parent control" of the custom control that orginally gave me problems..........................................
I really dont understand this,,, because according to example it should wok anyway regardless this line...
Given time I will try to recreate my problems in the WPFComposition example.... because I am affraid that my code will break again if the problem
not is clearly understod...