Hello.
I am trying to add a button to the BundleToolbarRegion of the Interaction view. I have read in the documentation that this region contains a BundleCustomButtonRegion which is a Multi-View, which means I should be able to add things to it (provided it is visible, which to me is a big 'if').
Here's what I have done so far.
Code for the button itself (I must admit that I do not know WPF. I have made a few views in the past through a mixture of copy-pasting and guesswork. So if there are any errors in my code, please let me know. I know this compiles, but that is not saying much.)
[code]<UserControl x:Class="[REDACTED].CustomViews.SurveyButton"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:common="clr-namespace:Genesyslab.Desktop.WPFCommon;assembly=Genesyslab.Desktop.WPFCommon"
xmlns:commonControls="clr-namespace:Genesyslab.Desktop.WPFCommon.Controls;assembly=Genesyslab.Desktop.WPFCommon"
mc:Ignorable="d"
d:DesignHeight="26" d:DesignWidth="26">
<Grid>
<commonControls:InteractionToolBarButton Click="buttonSurvey_Click" Name="buttonSurvey" ButtonStyle="{Binding ButtonStyle}"
ToolTip="{Binding ToolTipButtonReply}"
AutomationProperties.Name="{Binding PropertiesNameButtonReply}">
<StackPanel Orientation="Horizontal">
<commonControls:MagicImage Width="24" Height="24" Source="Survey.png"/>
</StackPanel>
</commonControls:InteractionToolBarButton>
</Grid>
</UserControl>[/code]
Code for the interface:
[code]public interface ISurveyButtonView : IView
{
IInteractionViewModel Model { get; set; }
}[/code]
Code for the xaml.cs:
[code]public partial class SurveyButton : UserControl, ISurveyButtonView
{
readonly IObjectContainer container;
readonly IViewEventManager viewEventManager;
public SurveyButton(IInteractionViewModel viewModel, IObjectContainer container, IViewEventManager viewEventManager)
{
this.container = container;
this.viewEventManager = viewEventManager;
this.Model = viewModel;//Se le puede pedir interaction.
InitializeComponent();
}
private void buttonSurvey_Click(object sender, System.Windows.RoutedEventArgs e)
{
//TODO
}
public Genesyslab.Desktop.Modules.Windows.Interactions.IInteractionViewModel Model
{
get { return this.DataContext as IInteractionViewModel; }
set { this.DataContext = value; }
}
public object Context { get; set; }
public void Create()
{
if (!(Model.Interaction is IInteractionInboundEmail)){
this.Visibility = Visibility.Hidden;//I may need to change this but that's another story.
}
}
public void Destroy()
{
}
}[/code]
And finally, code for the addition of the view to the region within the initialization of the module:
[code]container.RegisterType<ISurveyButtonView, SurveyButton>();
viewManager.ViewsByRegionName["BundleCustomButtonRegion"].Add(
new ViewActivator() { ViewType = typeof(ISurveyButtonView), ViewName = "SurveyButton", ActivateView = true}
);[/code]
I have tried debugging this with different types of interactions and the button view is never created (the Create method is not invoked and the button cannot be seen).
Could anyone please tell me what I'm missing and/or doing wrong?
Thank you in advance.