您的位置:首页 > 其它

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,

<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...
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: