Integrate in the AntonyHubs Navigation Panel

Tl;Dr;

  1. Write an antony registry and register it into the antonyHub ( Howto write an antony registry )

  2. Register an AntonyHubMenuNode into the IServiceCollection

  3. Setting at least the identifier, DisplayName, and GenerateViewAsync properties

General

As a module developer you are able to put menu nodes to the AntonyHub’s NavigationPage. This nodes are designed to add functionality for the configuration of your module itself. For example to configure MailBoxes in the MailAddin or provide credentials to access the external service you might integrate in.

Every Node in the navigation’s tree needs a unified identifier. For your nodes you need to generate them manually. Be sure that these identifiers are unique over the whole hub.

Also behind every node you need to define an AntonyView which is displayed by the hub, as the user clicks on you MenuNode.

To get a tree structure you can specify a ParentIdentifier on each node. If you want to create a Sub-MenuNode in an existing Node you can simply put the node’s identifier in the ParentIdentifiers property.

Example

As an example we took the build-in CommentMenuNode of the Hub. This MenuNode is shown under the “Umgebungsverwaltung”. Lines 12 to 22 are initializing the relevant notes properties. As you can see the Identifier and ParentIdentifier are setup and also the DisplayName. All on all it is straight forward.

As the CommentMenuNode is registered within the DI Container you are able to inject you needed services within the constructor. In this case we inject the CommentViewModel to bind the generated view to. Of course the CommentViewModel needs to be registered within the DI container too. Of course you can also inject some relevant services like the IAntonyHubClient service to do something with the hub.

public class CommentMenuNode : AntonyHubMenuNode { private Func<CommentViewModel> _viewModelGetter; public CommentMenuNode(Func<CommentViewModel> viewModelGetter) { _viewModelGetter = viewModelGetter; } public CommentMenuNode() { this.Identifier = "comments"; this.DisplayName = "Hinweise"; this.ParentIdentifier = "Subscriptions"; this.ImageAsSvg = Resources.comment; this.GenerateViewAsync = async (reporter) => { var theViewModel = _viewModelGetter(); var commentView = new CommentView(); commentView.DataContext = theViewModel; return AntonyView.FromWpfFrameworkElement(commentView); }; } }

Where to get the ParentIdentifier?

You might have the Problem that you don’t know the ParentIdentifier of a MenuNode you wants to be shown under. To get this you can simply make a left mouse Triple-Click on the node. A little MessageBox will inform you that the identifier is copied to the clipboard.

Conclusion

Thanks for reading the complicated manual. i hope it helped Feel free to inform us, if you have troubles.