Silverlight Databinding
-
Upload
srisakthi-kannan -
Category
Technology
-
view
857 -
download
2
description
Transcript of Silverlight Databinding
![Page 1: Silverlight Databinding](https://reader035.fdocuments.us/reader035/viewer/2022062405/55617388d8b42ade208b49f3/html5/thumbnails/1.jpg)
DATABINDINGDATABINDINGusingusing
silverlight 2.0silverlight 2.0
SRISAKTHISRISAKTHICHIPKIDZCHIPKIDZ
![Page 2: Silverlight Databinding](https://reader035.fdocuments.us/reader035/viewer/2022062405/55617388d8b42ade208b49f3/html5/thumbnails/2.jpg)
AGENDAAGENDA
DataBindingDataBinding Binding ExpressionBinding Expression DataTemplateDataTemplate ConvertersConverters BindingModesBindingModes
![Page 3: Silverlight Databinding](https://reader035.fdocuments.us/reader035/viewer/2022062405/55617388d8b42ade208b49f3/html5/thumbnails/3.jpg)
DATABINDINGDATABINDING Databinding is a mechanism for moving the data from Databinding is a mechanism for moving the data from
objects into UI controls.objects into UI controls.
Databinding is the magic that that sits between our Databinding is the magic that that sits between our objects (know as a objects (know as a modelmodel) and the UI (known as a ) and the UI (known as a viewview).).
![Page 4: Silverlight Databinding](https://reader035.fdocuments.us/reader035/viewer/2022062405/55617388d8b42ade208b49f3/html5/thumbnails/4.jpg)
BINDING EXPRESSIONBINDING EXPRESSION
For basic databindingFor basic databinding 11.Binding Expression.Binding Expression 22.Data context .Data context A binding expression is used inside the XAML to A binding expression is used inside the XAML to
describe the name of the property that we want describe the name of the property that we want fetched from the model.fetched from the model.For example,For example,
<TextBlock Text="{Binding Name}" /> <TextBlock Text="{Binding Name}" />
![Page 5: Silverlight Databinding](https://reader035.fdocuments.us/reader035/viewer/2022062405/55617388d8b42ade208b49f3/html5/thumbnails/5.jpg)
Contd…Contd…
Most Silverlight controls will expose a DataContext Most Silverlight controls will expose a DataContext property. property.
For exampleFor example Employee employee = new Employee() Employee employee = new Employee() {{ Name=“Sakthi”;Name=“Sakthi”; } this.DataContext = employee;} this.DataContext = employee;
![Page 6: Silverlight Databinding](https://reader035.fdocuments.us/reader035/viewer/2022062405/55617388d8b42ade208b49f3/html5/thumbnails/6.jpg)
DATATEMPLATEDATATEMPLATE
A A data templatedata template describes the controls we want to use describes the controls we want to use when displaying each individual item in a collection.when displaying each individual item in a collection.
For exampleFor example<ListBox ItemsSource="{Binding}"> <ListBox ItemsSource="{Binding}"> <ListBox.ItemTemplate> <ListBox.ItemTemplate> <DataTemplate> <DataTemplate> <TextBlock Text="{Binding Name}"></TextBlock> <TextBlock Text="{Binding Name}"></TextBlock> </DataTemplate></DataTemplate></ListBox.ItemTemplate> </ListBox.ItemTemplate>
![Page 7: Silverlight Databinding](https://reader035.fdocuments.us/reader035/viewer/2022062405/55617388d8b42ade208b49f3/html5/thumbnails/7.jpg)
CONVERTERCONVERTER
Silverlight allows you to dynamically convert values Silverlight allows you to dynamically convert values during data binding.during data binding.
You can accomplish this by first creating a custom class You can accomplish this by first creating a custom class that represents a value converter. that represents a value converter.
This value converter can then be referenced in an This value converter can then be referenced in an XAML file. XAML file.
![Page 8: Silverlight Databinding](https://reader035.fdocuments.us/reader035/viewer/2022062405/55617388d8b42ade208b49f3/html5/thumbnails/8.jpg)
BINDING MODESBINDING MODES Three BindingModes are availableThree BindingModes are available
1.1.One-way BindingOne-way Binding
2.2.Two-way BindingTwo-way Binding
3.3.OneTime BindingOneTime Binding
The One-way BindingMode is the default option used when you create a Binding.
![Page 9: Silverlight Databinding](https://reader035.fdocuments.us/reader035/viewer/2022062405/55617388d8b42ade208b49f3/html5/thumbnails/9.jpg)
Contd…Contd…
This option gives you the ability to automatically receive changes from a source property.
![Page 10: Silverlight Databinding](https://reader035.fdocuments.us/reader035/viewer/2022062405/55617388d8b42ade208b49f3/html5/thumbnails/10.jpg)
Contd…Contd…
Two-way binding enables two properties that are bound to change each other.
The OneTime option sets the target property to the source property when a binding is initially made.
![Page 11: Silverlight Databinding](https://reader035.fdocuments.us/reader035/viewer/2022062405/55617388d8b42ade208b49f3/html5/thumbnails/11.jpg)
CONCLUSIONCONCLUSION Silverlight data binding features are flexible and Silverlight data binding features are flexible and
powerful, and provide you with everything you need to powerful, and provide you with everything you need to build an effective business application.build an effective business application.
It provide properties such as It provide properties such as 1.CanUserResizeColumns1.CanUserResizeColumns 2.GridlinesVisibility2.GridlinesVisibility 3.HeaderVisibility3.HeaderVisibility 4.RowDetailsVisibility and RowDetailsTemplate4.RowDetailsVisibility and RowDetailsTemplate 5.SelectionMode5.SelectionMode 6.Opacity6.Opacity
![Page 12: Silverlight Databinding](https://reader035.fdocuments.us/reader035/viewer/2022062405/55617388d8b42ade208b49f3/html5/thumbnails/12.jpg)
www.shakthee-silverlight.blogspot.comwww.shakthee-silverlight.blogspot.com
www.shakthee.webs.comwww.shakthee.webs.com
![Page 13: Silverlight Databinding](https://reader035.fdocuments.us/reader035/viewer/2022062405/55617388d8b42ade208b49f3/html5/thumbnails/13.jpg)
THANK YOUTHANK YOU