开发者

C# - Silverlight - How to i bind the width of an element to an other element such that its OneWay Binding?

开发者 https://www.devze.com 2023-03-09 02:29 出处:网络
i have two TextBoxes with x:Name=\"TextBoxName\" and x:Name=\"TextBoxPhone\" i want to be able to bind the width of TextBoxName to TextBoxPhone such that if TextBoxPhone Width changes i want the width

i have two TextBoxes with x:Name="TextBoxName" and x:Name="TextBoxPhone" i want to be able to bind the width of TextBoxName to TextBoxPhone such that if TextBoxPhone Width changes i want the width of TextBoxName to change too how do开发者_如何学Python i do it?


In Silverlight 3:

For the TextBox called TextBoxName set Width="{Binding Width, ElementName=TextBoxPhone}"

Good example here http://www.silverlightshow.net/tips/XAML-Element-Binding.aspx

In Silverlight 2:

You would need to do some more work. Example here: http://www.scottlogic.co.uk/blog/colin/2009/02/elementname-binding-in-silverlight-via-attached-behaviours/


Is this what you're looking for?

<TextBox Height="23" HorizontalAlignment="Left" Margin="190,81,0,0" Name="TextBoxName" VerticalAlignment="Top" Width="{Binding ElementName=TextBoxPhone, Path=Width, Mode=OneWay}" />
<TextBox Height="23" HorizontalAlignment="Left" Margin="194,192,0,0" Name="TextBoxPhone" VerticalAlignment="Top" Width="120" />


<TextBox Name="TextBoxName" Width="{Binding ElementName=TextBoxPhone, Path=Width, Mode=OneWay}" />

0

精彩评论

暂无评论...
验证码 换一张
取 消