Search

Documentation

XnaBind provides a simple way to perform property data binding in Xna Games.
With XnaBind you can create a dynamic link between two object properties and let the update themselves automatically.

The code was written in C# and focused on Xna game development, but it can be used in all .Net project and also with another programming languages.

To learn more how to use XnaBind please see Tutorials and Samples pages.

Requirements
XnaBind requires .Net Framework 3.5 or higher because it uses Lambda Expressions to offer more power when link two properties.
Xna Game Studio 3/3.5 on Visual Studio 2008 or Visual C# Express 2008.

Classes

To understand better how XnaBind works see the description of its class architecture.
The project is very objective and it is composed by three classes: Bind, BindDirection and BindableProperty

Bind Class

A dynamic bind between two properties

Simple Bind Class
public class Bind<T>
Compound Bind Class
public class Bind<T1,T2>
Simple Bind ClassCompound Bind Class

Examples
//Simple Bind
this.bind1 = new Bind<float>(sprite1X, sprite2.X, BindDirection.OneWay);

//Simple Bind with Lambda Expressions
this.bind2 = new Bind<float>(sprite1X, sprite2.X, x => x + 5);

//Compound Bind
this.bind3 = new Bind<float, string>(sprite1X, label1.Text, BindDirection.OneWay);

//Compound Bind with Lambda Expressions
this.bind4 = new Bind<float, string>(sprite1X, label1.Text, x => "x=" + x + "px");

BindDirection Enumeration

Represents the directions the properties will be bind.

public enum BindDirection
BindDirection Enumeration

Examples
//OneWay
this.bind1 = new Bind<float>(sprite1.Y, sprite1.Y, BindDirection.OneWay);

//TwoWay
this.bind2 = new Bind<float>(sprite1.Y, sprite1.Y, BindDirection.TwoWay);

BindableProperty Class

A property container that fires a Changed Event when the property value is set

public class BindableProperty<T> : IConvertible
BindableProperty Class

Examples
//BindableProperty float
public BindableProperty<float> X { get; set; }

//BindableProperty string
public BindableProperty<string> Text { get; set; }

Complete Class Diagram

Here is the class diagram for XnaBind project show all interface implementations and relationship between classes.
The Class Diagram inclued in the source can be visualized only by Visual Studio 2008.
XnaBind Class Diagram
Last edited Jan 14 2010 at 7:57 PM by shinji, version 4
Comments
No comments yet.

Updating...
© 2006-2012 Microsoft | Get Help | Privacy Statement | Terms of Use | Code of Conduct | Advertise With Us | Version 2012.1.11.18365