Kanzi  3.9.4
Kanzi Studio API
Binding Interface Reference

Configure binding arguments. More...

Inheritance diagram for Binding:
[legend]
Collaboration diagram for Binding:
[legend]

Properties

string Code [get, set]
 Gets or sets the binding expression. More...
 
bool IsBindingActive [get]
 Checks whether the binding is active. More...
 
bool IsBindingEnabled [get, set]
 Gets or sets a value indicating whether this binding is enabled More...
 
bool IsCodeValid [get]
 Checks whether the binding expression is valid. More...
 
Property Property [get]
 Gets the property the binding binds. More...
 
AnimationTargetPropertyAttributeEnum PropertyAttribute [get, set]
 Gets or sets the property field that the binding binds. More...
 

Detailed Description

Configure binding arguments.

See also
BindingHost

Property Documentation

◆ Code

string Code
getset

Gets or sets the binding expression.

Examples

To set the binding expression of a binding:

// This example creates a node, adds a binding to it, and then changes the binding expression.
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");
// Set the binding expression to 5 so that the binding now binds the scale of the Text Block 2D node on the x axis
// to the location of the node on the y axis.
binding.Code = "{@./LayoutTransformation}.TranslationY";
}

◆ IsBindingActive

bool IsBindingActive
get

Checks whether the binding is active.

Examples

To check whether a binding is active:

// This example creates a node, adds a binding to it, and checks if the binding expression is active.
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,
"@./LayoutTransformation}.TranslationY");
// If the binding is active, print a notification to the Kanzi Studio Log window.
if (binding.IsBindingActive)
{
studio.Log("Binding is inactive in the " + textBlock.Name + " node");
}
}

◆ IsBindingEnabled

bool IsBindingEnabled
getset

Gets or sets a value indicating whether this binding is enabled

Examples

To make the binding disabled:

// This example creates a node, adds a binding to it, set the biding disabled and check whether it is enabled or not.
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, "@./LayoutTransformation}.TranslationY");
binding.IsBindingEnabled = false;
// If the binding is disabled, print a notification to the Kanzi Studio Log window.
if (!binding.IsBindingEnabled)
{
studio.Log("Binding is enabled in the " + textBlock.Name + " node");
}
}

◆ IsCodeValid

bool IsCodeValid
get

Checks whether the binding expression is valid.

Examples

To check whether a binding expression is valid:

// This example creates a node, adds a binding to it, and checks if the binding expression is valid.
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, "@./LayoutTransformation}.TranslationY");
// If the binding expression has an error, print a notification to the Kanzi Studio Log window.
if (!binding.IsCodeValid)
{
studio.Log("Invalid binding expression " + binding.Code + " in the " + textBlock.Name + " node");
}
}

◆ Property

Gets the property the binding binds.

Examples

To get the property a binding binds:

// This example creates a node, adds a binding to it, and prints the name of the binding property.
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");
// Print the name of the binding property to the Kanzi Studio Log window.
studio.Log("Binding Property: " + binding.Property.Name);
}

◆ PropertyAttribute

AnimationTargetPropertyAttributeEnum PropertyAttribute
getset

Gets or sets the property field that the binding binds.

Examples

To set the property field that a binding binds:

// This example creates a node, adds a binding to it, and then changes the binding property field.
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");
// Set the property field to Scale Y so that the binding now binds the scale of the Text Block 2D node
// on the y axis to the constant value 10.
binding.PropertyAttribute = AnimationTargetPropertyAttributeEnum.SCALE_Y;
}