Element to Element Binding in Silverlight
2009-09-16 11:05
127 查看
In the old days, if you want a TextBlock to display the Silder value, you can use two ways,
1. Create a business object to hold the Silder Value and then bind it to the TextBlock objec.
2. You can write some code in the Slider value changed event handler to update the value in the TextBlock
But if there are more Sliders and more TextBlocks need to do the same thing, neither of above ways is an easy way.
Fortunately, we can use the "Element to Element Binding" feature in Silverlight. The Syntax is as follows,
You can only bind the element which on the page. I tried to bind the element which i created by code, but not working...
1. Create a business object to hold the Silder Value and then bind it to the TextBlock objec.
2. You can write some code in the Slider value changed event handler to update the value in the TextBlock
But if there are more Sliders and more TextBlocks need to do the same thing, neither of above ways is an easy way.
Fortunately, we can use the "Element to Element Binding" feature in Silverlight. The Syntax is as follows,
<Slider Minimum="0" Maximum="100" x:Name="MySlider" /> <TextBlock Text="{Binding Value, Mode=OneWay, ElementName=MySlider}" />
You can only bind the element which on the page. I tried to bind the element which i created by code, but not working...
相关文章推荐
- 稳扎稳打Silverlight(39) - 3.0编程之Element to Element Binding, 通信之二进制XML通信, 本地连接
- 稳扎稳打Silverlight(40) - 3.0绑定之Element to Element Binding, RelativeSource; 样式之动态修改样式, 样式继承, 自定义光标
- Tips: Save some typing when binding values to UI in WPF/Silverlight
- 稳扎稳打Silverlight(40) - 3.0绑定之Element to Element Binding, RelativeSource
- 稳扎稳打Silverlight(40) - 3.0绑定之Element to Element Binding, RelativeSource; 样式之动态修改样式, 样式继承, 自定义光标
- Binding to Resources in Silverlight/WPF
- Binding Events to Methods in the Silverlight MVVM View Models
- Pro Silverlight 3 in C# - Element-to-Element Binding
- Binding to a dictionary in Silverlight with INotifyPropertyChanged
- Binding UI Events from View to commands in ViewModel in Silverlight 4(转)
- How to Embed Silverlight Content in HTML
- IE inline edit how to make hidden element actually hide
- JS. How to replace html element with another element/text, represented in string?
- Pasting pictures from clipboard to SharePoint in browser, via Silverlight 5
- ToolTip for Disabled Element in Silverlight
- it has a DefiningQuery and no InsertFunction element exists in the ModificationFunctionMapping element to support the current op
- Data Binding in Silverlight 4.0
- How to Display DataSet in Silverlight DataGrid
- How to put a space character before option text in a HTML select element?
- An Introduction to XML Data Binding in C++