首页 / 软件开发 / Silverlight / 稳扎稳打Silverlight(40) - 3.0绑定之Element to Element Binding,RelativeSo
稳扎稳打Silverlight(40) - 3.0绑定之Element to Element Binding,RelativeSo2010-05-10 博客园 webabcd返回“”稳扎稳打Silverlight(40) - 3.0绑定之Element to Element Binding,RelativeSource,样式之动态修改样式,样式继承,自定义光标介绍Silverlight 3.0 绑定的新增功能,样式相关的新增功能Element to Element Binding - Element 到 Element 之间的绑定RelativeSource - 一个扩展标记,用于指定关联数据源为 Self 或 TemplatedParent动态修改样式 - 在 Runtime 时修改样式样式继承 - 通过 BasedOn 使某样式可以继承自另一个样式自定义光标 - 通过 CaretBrush 自定义输入框的光标的样式在线DEMOhttp://www.cnblogs.com/webabcd/archive/2009/08/04/1538238.html示例1、Element to Element 绑定的演示Element2Element.xaml<navigation:Page x:Class="Silverlight30.Binding.Element2Element"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
d:DesignWidth="640" d:DesignHeight="480"
Title="Element to Element Binding Page">
<Grid x:Name="LayoutRoot">
<StackPanel VerticalAlignment="Top" HorizontalAlignment="Left">
<!--Element to Element 绑定的支持-->
<!--
绑定方式1:{Binding 绑定的属性名称, Mode=, ElementName=绑定的对象名称}
绑定方式2:{Binding ElementName=绑定的对象名称, Path=绑定的属性名称, Mode=}
Mode的可用值有:OneTime, OneWay, TwoWay
-->
<Slider x:Name="silder" Value="50" Minimum="1" Maximum="100" LargeChange="5" Width="500"></Slider>
<TextBox Text="{Binding Value, Mode=TwoWay, ElementName=silder}" />
<Slider Minimum="1" Maximum="100" LargeChange="5" Width="500"
Value="{Binding ElementName=textBox, Path=Text, Mode=TwoWay }"></Slider>
<TextBox x:Name="textBox" Text="50" />
</StackPanel>
</Grid>
</navigation:Page>