Public Member Functions | Properties | List of all members
BindingHost Interface Reference

Configure bindings. More...

Public Member Functions

Binding CreateBinding (Property property, AnimationTargetPropertyAttributeEnum attribute, string code)
 Creates and configures a binding. More...
 
Binding CreateBinding (Binding sourceBinding)
 Creates a binding by copying an existing binding. More...
 
void DeleteBinding (Binding binding)
 Deletes a binding. More...
 

Properties

IEnumerable< BindingBindings [get]
 Gets the bindings in a BindingHost. More...
 

Detailed Description

Configure bindings.

This class represents a binding host which can have bindings.

Use bindings to update properties or property attributes of one node with the properties or property attributes of other nodes. Bindings allow nodes to automatically update the values of their properties in response to the changing attributes in other nodes or the occurrence of some external event.

See also
Binding

Member Function Documentation

Binding CreateBinding ( Property  property,
AnimationTargetPropertyAttributeEnum  attribute,
string  code 
)

Creates and configures a binding.

Parameters
propertyThe property you want to bind
attributeThe property attribute you want to bind
codeThe binding expression
Returns
The binding you create with this function.
See also
Binding

Examples

To create a binding:

// This example creates a Box node and binds the scale of the node on the y axis
// to the location of the node along the x axis multiplied by 5.
public void Execute(PluginCommandParameter parameter)
{
// Get the Screens/Screen/RootPage/Viewport 2D/Scene node.
var scene = studio.ActiveProject.GetProjectItem("Screens/Screen/RootPage/Viewport 2D/Scene");
// Create a Box node named Box in the Scene node.
var box = studio.ActiveProject.CreateProjectItem<BoxMeshNode>(scene.GenerateUniqueChildName("Box"), scene);
// Create a binding which binds the scale of the Box node on the y axis to
// the location of the Box node along the x axis and multiplies it by 5.
box.CreateBinding(
Properties.Node3DLayoutTransformation, AnimationTargetPropertyAttributeEnum.SCALE_Y, "{@./LayoutTransformation}.TranslationX*5");
}
Binding CreateBinding ( Binding  sourceBinding)

Creates a binding by copying an existing binding.

Parameters
sourceBindingThe binding you want to copy to create a new binding.
Returns
The binding you create with this function.

Examples

To create a binding from an existing binding:

// This example creates a Text Block 2D node and binds the scale of the node on the x axis to the value 10.
// It then creates another Text Block 2D node and copies the binding to that node.
public void Execute(PluginCommandParameter parameter)
{
// Get the Screens/Screen/RootPage node.
var rootPage = studio.ActiveProject.GetProjectItem("Screens/Screen/RootPage");
// Create a Text Block 2D node in the RootPage node.
var textBlock = studio.ActiveProject.CreateProjectItem<TextBlock2D>(rootPage.GenerateUniqueChildName("Text Block 2D"), rootPage);
// Create a binding which binds the scale of the Text Block 2D node on the x axis to the constant value 10.
var binding = textBlock.CreateBinding(Properties.Node2DLayoutTransformation, AnimationTargetPropertyAttributeEnum.SCALE_X, "10");
// Create another Text Block 2D node in the RootPage node.
var textBlock2 = studio.ActiveProject.CreateProjectItem<TextBlock2D>(rootPage.GenerateUniqueChildName("Text Block 2D"), rootPage);
// Create a binding for the second Text Block 2D node by copying the binding in the first Text Block 2D node.
textBlock2.CreateBinding(binding);
}
void DeleteBinding ( Binding  binding)

Deletes a binding.

Parameters
bindingThe binding you want to delete.

Examples

To delete a binding:

// This example creates a Text Block 2D node and binds the scale of the node on the x axis to the value 10.
// It then creates another Text Block 2D node, copies the binding to that node, and deletes the binding from
// the first Text Block 2D node.
public void Execute(PluginCommandParameter parameter)
{
// Get the Screens/Screen/RootPage node.
var rootPage = studio.ActiveProject.GetProjectItem("Screens/Screen/RootPage");
// Create a Text Block 2D node in the RootPage node.
var textBlock = studio.ActiveProject.CreateProjectItem<TextBlock2D>(rootPage.GenerateUniqueChildName("Text Block 2D"), rootPage);
// Create a binding which binds the scale of the Text Block 2D node on the x axis to the constant value 10.
var binding = textBlock.CreateBinding(Properties.Node2DLayoutTransformation, AnimationTargetPropertyAttributeEnum.SCALE_X, "10");
// Create another Text Block 2D node in the RootPage node.
var textBlock2 = studio.ActiveProject.CreateProjectItem<TextBlock2D>(rootPage.GenerateUniqueChildName("Text Block 2D"), rootPage);
// Create a binding for the second Text Block 2D node by copying the binding in the first Text Block 2D node.
textBlock2.CreateBinding(binding);
// Delete the binding from the first Text Block 2D node.
textBlock.DeleteBinding(binding);
}

Property Documentation

IEnumerable<Binding> Bindings
get

Gets the bindings in a BindingHost.

Examples

To get the bindings in a node:

// This example creates a Text Block 2D node, adds two bindings to it, and modifies the second binding.
// It then prints the property, property attribute, and binding expression of both bindings to the Kanzi Studio Log window.
public void Execute(PluginCommandParameter parameter)
{
// Get the Screens/Screen/RootPage node.
var rootPage = studio.ActiveProject.GetProjectItem("Screens/Screen/RootPage");
// Create a Text Block 2D node in the RootPage node.
var textBlock = studio.ActiveProject.CreateProjectItem<TextBlock2D>(rootPage.GenerateUniqueChildName("Text Block 2D"), rootPage);
// Create a binding which binds the scale of the Text Block 2D node on the x axis to the constant value 10.
var binding1 = textBlock.CreateBinding(Properties.Node2DLayoutTransformation, AnimationTargetPropertyAttributeEnum.SCALE_X, "10");
// Create a binding for the second Text Block 2D node by copying the binding in the first Text Block 2D node.
var binding2 = textBlock.CreateBinding(binding1);
// Set the property attribute of the binding in the second Text Block 2D node so that the binding binds
// the scale of the Text Block 2D node on the y axis to the constant value 10.
binding2.PropertyAttribute = AnimationTargetPropertyAttributeEnum.SCALE_Y;
// Print the property, property attribute, and binding expression of each binding in the Text Block 2D node
// to the Kanzi Studio Log window.
studio.Log("Bindings in the " + textBlock.Name + " node:");
foreach (var binding in textBlock.Bindings)
{
studio.Log(binding.Property.Name + " " + binding.PropertyAttribute + ": " + binding.Code);
}
}