I have Implemented the MAF Framework, creating a pipeline and an AddIn which sends a
<!-- language-all: lang-cc -->
UserControl
to my host which is a plugin itself.
The control to be sent to the host is written as below, it implements UserControl
and contains an additional string property:
Contract : public interface ITestSuiteUiContract : INativeHandleContract
AddInViews : public class TestSuiteUi : UserControl
HostViews : public abstract class AbstractTestSuiteUi : UserControl
The host loads the AddIn and the requested UI. I can call methods, but I can't display my AddIn
UI object into my host container:
ViewModel: TestSuiteUiContainer = _TestSuiteLoader.LoadedTestSuite.GetTestSuiteWpfUiObjects()[0];`
View : `<ContentControl Content="{Binding TestSuiteUiContainer}"/>
unless I put it in a separate window
new Window { Content = TestSuiteUicontainer }.Show();
or even if I put the hole plugin view in a separate window.
My plugin is displaying all UserControl
Objects exept my AddIn ui object.
Here's my Hostside TestSuiteUi contract to
view adapter :
public TestSuiteUiContractToViewAdapter(TestSuiteUiContract contract)
{
_contract = contract;
_handle = new ContractHandle(_contract);
string aqn = typeof(INativeHandleContract).AssemblyQualifiedName;
INativeHandleContract inhc = (INativeHandleContract)SourceContract.QueryContract(aqn);
FrameworkElement fe = (FrameworkElement)FrameworkElementAdapters.ContractToViewAdapter(inhc);
this.Content = fe;
}
And here's the list returned by my AddIn:
public List<AbstractTestSuiteUi> GetTestSuiteWpfUiObjects()
{
var list = new List<AbstractTestSuiteUi>();
for (int i = 0; i < SourceContract.GetTestSuiteWpfUiObjects().GetCount(); i++)
{
list.Add(Adapt.ToView<ITestSuiteUiContract, AbstractTestSuiteUi, TestSuiteUiContractToViewAdapter>(SourceContract.GetTestSuiteWpfUiObjects().GetItem(i)));
}
return list;
}
Here are methods added to my
TestSuiteUiViewTocontractAdapter:
public override IContract QueryContract(string contractIdentifier)
{
if (contractIdentifier.Equals(typeof(INativeHandleContract).AssemblyQualifiedName))
{
return FrameworkElementAdapters.ViewToContractAdapter(this.SourceView);
}
return base.QueryContract(contractIdentifier);
}
[SecurityPermissionAttribute(SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode)]
public IntPtr GetHandle()
{
return FrameworkElementAdapters.ViewToContractAdapter(this.SourceView).GetHandle();
}
In case someone faces the same issue, here's the answer found in msdn forum : http://social.msdn.microsoft.com/Forums/vstudio/en-US/cd30e928-31c8-4352-b86a-c6bcd64a3192/addin-apperence-issuein-wpf?forum=wpf