microsoft / xaml-designer-extensibility

Extensibility sample code for the Visual Studio XAML Designer
MIT License
67 stars 29 forks source link

ActionToken value? #26

Open arivoir opened 4 years ago

arivoir commented 4 years ago

I'm wondering how the ActionToken class works.

https://github.com/microsoft/xaml-designer-extensibility/blob/master/documents/xaml-suggested-actions/xaml-designer-suggested-actions-extensibility.md

thsparks commented 3 years ago

The ActionToken class allows us to lookup and refer to specific actions or action groups within a provider.

To answer your questions:

  1. We cannot use property name because ActionGroups don't have a property, and not all Actions refer to one either. (For example, Link Actions and Command Actions may not.)
  2. The "value" parameter defines a unique integer id for the given ActionToken. All ActionTokens should be assigned one. If you don't, it may not work. However, if you create an ActionGroup or Action without a token, that is okay. You just won't be able to look it up or refer to it later.
  3. If the same ActionToken value is used for multiple Actions/ActionGroups within a provider, that will also break your ability to look them up later on. If you're inheriting from an existing ActionProvider and wish to avoid duplicates, you can use the Last_Token field to ensure that you don't conflict with any tokens from inherited types. You can see an example of this in our Example for Inherited Controls.

Hopefully that answers your questions. We have some additional documentation on ActionTokens here: Suggested Actions Tokens. Please also feel free to follow up on this thread if you have any more questions, or close the thread if you're satisfied.

Thanks, Thomas