Author Topic: WDE extensions: title on a Workplace tab  (Read 3296 times)

Offline Gabi

  • Jr. Member
  • **
  • Posts: 64
  • Karma: 0
WDE extensions: title on a Workplace tab
« on: December 30, 2015, 06:20:34 PM »
Hello. I'm writing an extension for WDE 8.5. I have added a view to the ToolbarWorkplaceRegion as follows:

[code]
            container.RegisterType<IBrowserViewModel, BrowserViewModel>();
            container.RegisterType<IBrowserView, BrowserView>();
            container.RegisterType<IButtonView, ButtonView>();
          Add<IBrowserView>("ToolbarWorkplaceRegion", "Browser");
          Add<IButtonView>("ToolbarHamburgerButtonRegion", "Open Browser");  [/code]


With:
[code]
        internal void Add<T>(string Region, string Name)
        {
            this.viewManager.ViewsByRegionName[Region].Add(
                  new ViewActivator() { ViewType = typeof(T), ViewName = Name });
        }[/code]

The browser was added as expected. However, the corresponding tab has the title "My Workspace" rather than "Browser" and, furthermore, when a different tab is selected, the title of the browser tab becomes empty. When the browser tab is selected again, its title become "My Workspace" again.

Is there a way to set the title for the tab, and make it permanent? (That is, make the title stay when a different tab is selected).

Thanks in advance.

Offline Gabi

  • Jr. Member
  • **
  • Posts: 64
  • Karma: 0
Re: WDE extensions: title on a Workplace tab
« Reply #1 on: January 08, 2016, 02:22:51 PM »
I found the answer to this question, thanks to the developers at Interaxa Brazil.

I'll post it here in case anyone else has the same problem.

Step 1: remove the default constructor from the BrowserView class, and replace it by a constructor that takes the model as a parameter:

[code]
public BrowserView(IBrowserViewModel modl)
        {
            this.model = modl;
            InitializeComponent();

            Height = double.NaN;
            Width = double.NaN;

          ...Whatever initialization operations are desired.
        }
[/code]

Step 2: override the Name property of the model (BrowserViewModel class):

[code]
        new public string Name { get { return "Browser"; } }
[/code]

Step 3: set the Header property in the model (BrowserViewModel class):

[code]
string header = "Browser";


        public string Header
        {
            get
            {
                return header;
            }
            set
            {
                if (header != value)
                {
                    header = value;
                    OnPropertyChanged("Header");
                }
            }
        }
[/code]

That did the trick.

Best wishes to everyone,
Gabi

Offline Kubig

  • Hero Member
  • *****
  • Posts: 2752
  • Karma: 44
Re: WDE extensions: title on a Workplace tab
« Reply #2 on: January 08, 2016, 02:25:05 PM »
You can find similiar approach within provided IWS/WDE extension examples.

Offline Gabi

  • Jr. Member
  • **
  • Posts: 64
  • Karma: 0
Re: WDE extensions: title on a Workplace tab
« Reply #3 on: January 08, 2016, 02:31:43 PM »
Thanks. I was actually basing my work on an IWS project which was in turn based on a sample, but I clearly couldn't get everything right when migrating from 8.1 to 8.5, because it did not work. Then the Brazil crew sent me a nearly working sample, but it lacked the name on the tab. And now, finally, they sent me a new sample from which I inferred the way to do it.

It would be nice if there were guides of how to write certain common extensions without having to reverse-engineer the extension samples. Personally, whenever I post a problem here and then find the answer, I will post the answer too. It may help someone in the future.

Offline Kubig

  • Hero Member
  • *****
  • Posts: 2752
  • Karma: 44
Re: WDE extensions: title on a Workplace tab
« Reply #4 on: January 08, 2016, 02:58:47 PM »
You can learn how to properly write to modules in PSDK training, where is all described in great detail. In general, it is not possible to write some guide "how to", because the used technology is changed dynamically and it is not related to the Genesys itself directly, but to the .Net patterns and MVVM model, so if you need some step-by-step guide, you can try to find any relevant document about MVVM technology, bootstrapers, etc.