I have question about create/add new button to existing view. Is it possible?
I want add button programatically to ContactInfoHistoryMultiRegion and exactly to ContactInformationView → DockPanelContactHistoryContent → Toolbar_Copy. I can’t access to it and I don’t know how to bite it. Did you have similar case?
thank you for answer. I know sample with button, I hope we talk about the same sample - I can create buttton in my NEW/OWN view, for example to ToolbarWorkplaceRegion I add new tab with button, right?
But my question is about existing view created default in WDE and more precisly I’m talking about Contacts History Tab. Or maybe I misunderstood you? Could you expand your thought?
I suppose to do something wrong or I don’t know about any method. I found where is my problem, I’m adding new ViewActivator to ContactTabBottomHistoryMultiRegion but this region doesn’t exist yet when ExtensionModule do Initialize() method.
public void Initialize()
{
container.RegisterType<IMyView, MyView>();
container.RegisterType<IMyViewModel, MyViewModel>();
}
then I made viewEventManager.Subscribe(CheckingEvent) which raise event after select email in ContactHistoryView
private void CheckingEvent(object obj)
{
string loadedAction = (obj as GenericEvent).Action[0].Action as string;
ViewActivator toolbarContainer = null;
if (loadedAction == "LoadInteractionInformation")
{
foreach (ViewActivator view in viewManager.ViewsByRegionName["ContactInfoHistoryMultiRegion"])
{
if (view.ViewName == "ContactInformationView")
{
viewManager.ViewsByRegionName["ContactTabBottomHistoryMultiRegion"].Add(
new ViewActivator()
{
ViewType = typeof(IMyView),
ViewName = "MyView",
ActivateView = true
}
);
break;
}
}
}
}
ViewActivator correctly add to region but unfortunately I don’t see result. If I will add the same view to eg. ToolbarWorkplaceRegion, I see my view. I can’t catch what is point.
I do not see any reason for iterating the existing view. You can directly add your custom view into existing region through the ViewManager. You just need to load your module after the ContactModule is loaded, thus why you cannot insert view right now as you trying to insert it so early.
I use ContactTabBottomHistoryMultiRegion region is several projects and never have encountered any issue on that.
My guess is I try too early to load my view that’s why I made own event but this is wrong way. Did you do the same way or do you load view by other method? I can’t catch where I am wrong.
Any keywords?
If I add ViewActivator by own event (when I have and I see ContactInfoHistoryMultiRegion region) then my view isn’t visible, should I use any method or something yet?
You are an amazing guy! Thank you so much. Such a small change, and allowed me to do it the way I wanted. I understand that the AddViewsToRegion method creates a non-existent region? Something like a placeholder?
Honestly, I am using both approaches (using AddViewsToRegion and ViewsByRegionName methods) and never have encountered issue with instanting custom view/part. I suppose there might be another issue that causes your custom part is not visible at all.
I don’t know why the .Add () method for viewManager did not work for the region “ContactTabBottomHistoryMultiRegion”. I checked the “ToolbarWorksheetRegion” region and it works fine.
The .AddViewsToRegion () method works well in both cases. Everything is located in the main module Initialize() loaded at startup (the same as ExtensionSampleModule). Maybe it’s a bug? Have I implemented something bad maybe? But I didn’t create something special, so I don’t think so. Any idea what could I check?
Parameter CreateNewRegionManager has been changed on true, that was my first think about it but didn’t change anything. If we talk about “interaction-workspace\views.ContactTabBottomHistoryMultiRegion.activate-order” parameter I guess we talk about CME options? If yes I checked it also and this doesn’t help me, of course I added view likewise 3 other (standard) views. This did not make my view work. Of course, ordering works correctly.
Just in case if someone found this valuable topic like me today. There is one more easy workaround. Like Kubig said, we just have to register our view after ContactsModule is loaded. We can achieve this by choosing right task in the .module-config file: