Share via


Implementing Argument Value Propagation

Retired Content

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies.
This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

Each time the user exits a field in a wizard, the Wizard Framework validates the field, and if the validation passes, it assigns the value to the corresponding argument. In some cases, you will want the value in one field to be used to set the default value of another field, along with its corresponding argument. This is referred to as value propagation.

The Guidance Automation Toolkit includes a value provider that is an expression evaluator. In the following XML code example, the expression evaluator is declared in the <TypeAlias> element as Evaluator. The Evaluator is set as the value provider for the argument TargetFile. The TargetFile argument is also defined to monitor changes of the ClassName argument. If both arguments were shown as fields of a wizard, the wizard would be notified by the Wizard Framework each time the TargetFile value changed. This would cause the wizard to update the corresponding field and complete the value propagation loop.

<TypeAlias Name="Evaluator" Type="Microsoft.Practices.RecipeFramework.Library.ValueProviders.ExpressionEvaluatorValueProvider,Microsoft.Practices.RecipeFramework.Library" />
...
<Argument Name="ClassName">
  <Converter Type="Microsoft.Practices.RecipeFramework.Library.Converters.CodeIdentifierStringConverter, Microsoft.Practices.RecipeFramework.Library"/>
</Argument>
<Argument Name="TargetFile">
  <ValueProvider Type="Evaluator" Expression="$(ClassName).cs">
  <MonitorArgument Name="ClassName" />
  </ValueProvider>
</Argument>

Note

You must always use the <MonitorArgument> element if you use the ExpressionEvaluatorValueProvider to obtain values from another argument. This ensures that the value will always be modified when it is supposed to be, regardless of the order in which the arguments are specified in the configuration file.

The value provider supplied with the Recipe Framework is an expression evaluator declared in the preceding code in the <TypeAlias> element as Evaluator. The Evaluator is associated with the argument TargetFile as its value provider. The TargetFile argument is also defined to monitor changes of the ClassName argument. If both arguments were shown as fields of a wizard, the wizard would be notified by the Wizard Framework each time the TargetFile value changed. This would cause the wizard to update the corresponding field. This would complete the value propagation loop.

Note

If you use the ExpressionEvaluatorValueProvider to provide an initial value to an argument of type color this will cause an exception.
You may also write your own value provider. Like an action, a value provider can use host services. For more information about using host services, see Obtaining and Using Host Services.

See also

Developing Wizards | Defining a Wizard | Defining a User Interface Value Editor | Writing Type Converters | Writing a Custom Wizard Page