Binding expressions in curly braces can contain an ActionScript expression that returns a value. For example, you can use the curly braces syntax for the following types of binding:
- A single bindable property inside curly braces
- String concatenation that includes a bindable property inside curly braces
- Calculations on a bindable property inside curly braces
- Conditional operations that evaluate a bindable property value
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
viewSourceURL="src/DataBindingActionScriptExpressionsSimple/index.html"
width="420" height="350"
>
<mx:Model id="myModel">
<myModel>
<!-- Perform simple property binding. -->
<a>{nameInput.text}</a>
<!-- Perform string concatenation. -->
<b>This is {nameInput.text}</b>
<!-- Perform a calculation. -->
<c>{(Number(numberInput.text) as Number) * 6 / 7}</c>
<!-- Perform a conditional operation using a ternary operator;
the person object contains a Boolean variable called isMale. -->
<d>{(isMale.selected) ? "Mr." : "Ms."} {nameInput.text}</d>
</myModel>
</mx:Model>
<mx:Panel
paddingBottom="10" paddingLeft="10" paddingRight="10" paddingTop="10"
width="100%" height="100%"
title="Binding expressions"
>
<mx:Form>
<mx:FormItem label="Last Name:">
<mx:TextInput id="nameInput"/>
</mx:FormItem>
<mx:FormItem label="Select sex:">
<mx:RadioButton
id="isMale"
label="Male"
groupName="gender"
selected="true"
/>
<mx:RadioButton
id="isFemale"
label="Female"
groupName="gender"
/>
</mx:FormItem>
<mx:FormItem label="Enter a number:">
<mx:TextInput id="numberInput" text="0"/>
</mx:FormItem>
</mx:Form>
<mx:Text text="{'Simple binding: '+myModel.a}"/>
<mx:Text text="{'String concatenation: '+myModel.b}"/>
<mx:Text text="{'Calculation: '+numberInput.text+' * 6 / 7 = '+myModel.c}"/>
<mx:Text text="{'Conditional: '+myModel.d}"/>
</mx:Panel>
</mx:Application>
分享到:
相关推荐
This book is all about the what and the why of binding to data sources in a Windows Forms application built using Visual Studio 2005. The book goes into great detail in explaining the rationale behind...
This is the final part of a three-part series on using LINQ to SQL: Part 1: Mapping Tables to Objects Part 2: Adding/Updating/Deleting Data Part 3: WPF Data Binding with LINQ to SQL These tutorials ...
The Data Binding Validator makes it easy and quick to validate fields in forms using data binding framework. Download Step 1: Add it in your root build.gradle at the end of repositories: allprojects {...
using (var context = new MyDbContext()) { var data = context.MyTable.ToList(); this.DataContext = data; } ``` 一旦有了数据,UI元素可以通过属性绑定自动显示这些数据。例如,一个`ListBox`可以绑定到一个...
Chapter 7 - Data Binding and Windows Forms Data-Bound Controls Chapter 8 - Constraints and Data Relations Chapter 9 - ADO.NET Exception Handling Chapter 10 - Working with the ODBC .NET Data ...
using System.Windows.Data; namespace WpfApp1 { public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); DataContext = new ViewModel { MyValue = "Hello, WPF!" }; ...
Using TRUNCATE Before Adding New Data Using JSON_INSERT Using JSON_REPLACE JSON_REMOVE JSON_SET JSON_UNQUOTE The Three JSON_MERGE Functions JSON_MERGE JSON_MERGE_PRESERVE JSON_DEPTH JSON_LENGTH JSON_...
Chapter 15 - Using ADO.NET in Xml Web Services Chapter 16 - ASP.NET Server Controls and Data Binding Chapter 17 - Building Real-World Web Applications Chapter 18 - Object-Relational ...
DA04 - Dynamic Method Binding DA05 - Advanced options for controlling... DA06 - Strongly Typed DataTables and... DA08 - No-Code n-Tier Applications DA09 - Why Data Abstract? DA10 - The Business ...
Data-oriented Development with AngularJS is a systematic learning guide that covers important AngularJS concepts such as data binding, dependency injection, directives, and so on. It also covers the ...
Binding: Hardcover Data Structures and Algorithms in Java, Second Edition is designed to be easy to read and understand although the topic itself is complicated. Algorithms are the procedures that ...
Windows Presentation Foundation 4.5 Cookbook的源码 Chapter 1: Foundations 7 ... Binding hierarchical data to a TreeView 217 Presenting data in a grid 220 Validating data 228 ......
using (ServiceHost host = new ServiceHost(typeof(MySecureService))) { host.AddServiceEndpoint( typeof(IMySecureService), new BasicHttpBinding(BasicHttpSecurityMode.Transport), ...
You will learn the core concepts involved in building web applications with Angular such as Data Binding, Routing, Dependency Injection, and much more. The book teaches how to build components and ...
<Button Content="Send Data" Command="{Binding SendCommand}" /> <TextBox Text="{Binding ReceivedData, Mode=OneWay}" /> ``` 在对应的ViewModel中,你需要实现`SendCommand`命令,并监听`SerialPort`的`...
C#, Data Binding, Chart Controls, .NET 4, Chart Control, MS Chart Platforms Desktop The samples environment contains a Getting Started section to help you start using the Chart controls quickly. The ...
You'll also implement key data-binding techniques that will make your user interfaces dynamic, and create personalized animations and visual effects within your user interfaces using Custom Renderers...
MVVM using Data Binding I wanted to experiment creating an MVVM structured project using the official Data Binding library, so I stripped back an old project of mine and replaced relevant codebase ...
You will learn about event binding and context binding properties using JSON and AJAX. You will then explore the features of KnockoutJS like mapping and how to go about it using controller options. ...