Volume Control
Application-specific hotkeys for Windows
VolumeControl.Core.ITemplateProvider Interface Reference

Provides a DataTemplate instance constructed in codebehind using FrameworkElementFactory. More...

Collaboration diagram for VolumeControl.Core.ITemplateProvider:

Public Member Functions

bool CanProvideDataTemplate (Type valueType)
 Checks if this ITemplateProvider instance can provide a DataTemplate for the specified valueType . More...
 
DataTemplate? ProvideDataTemplate (Type valueType)
 Gets the DataTemplate instance to use for displaying an editor control for the action setting's value. More...
 

Detailed Description

Provides a DataTemplate instance constructed in codebehind using FrameworkElementFactory.

Any public, non-static, non-abstract class that implements this interface can be specified for HotkeyActionSettingAttribute.DataTemplateProviderType.

To create an ITemplateProvider, first create a new class that implements it:

public class IntDataTemplateProvider : IDataTemplateProvider
{
public DataTemplate ProvideDataTemplate()
{
// Create a TextBox (via a factory) and bind its Text property to the action setting's Value property:
var textBoxFactory = new FrameworkElementFactory(typeof(TextBox));
textBoxFactory.SetBinding(TextBox.TextProperty, new Binding("Value"));
return new DataTemplate(typeof(int)) { VisualTree = textBoxFactory };
}
}
DataTemplate? ProvideDataTemplate(Type valueType)
Gets the DataTemplate instance to use for displaying an editor control for the action setting's value...

You would then specify the IntDataTemplateProvider type in your HotkeyActionSettingAttribute:

[HotkeyActionSetting("SomeSetting", typeof(int), typeof(IntDataTemplateProvider))]

Member Function Documentation

◆ CanProvideDataTemplate()

bool VolumeControl.Core.ITemplateProvider.CanProvideDataTemplate ( Type  valueType)

Checks if this ITemplateProvider instance can provide a DataTemplate for the specified valueType .

Parameters
valueTypeThe value type of the action setting to display in the template.
Returns
true when this instance supports the valueType ; otherwise false.

◆ ProvideDataTemplate()

DataTemplate? VolumeControl.Core.ITemplateProvider.ProvideDataTemplate ( Type  valueType)

Gets the DataTemplate instance to use for displaying an editor control for the action setting's value.

The returned DataTemplate will always be used with a DataContext of the Input.Actions.Settings.IActionSettingInstance instance for that action setting. Therefore, valid data binding paths can be relative to an Input.Actions.Settings.IActionSettingInstance instance, or absolute by directly specifying a binding Source.
A data binding path of "<see langword="Value"/>" will return the value instance of type HotkeyActionSettingAttribute.ValueType.
Return null to allow another data template to be selected.

Parameters
valueTypeThe value type of the action setting to display in the template.
Returns
A new DataTemplate instance for the specified valueType when successful; otherwise null.

The documentation for this interface was generated from the following file: