[英]Updating the value of a TextBlock on the basis of value of another TextBock in WPF using Dependency property
In my XAML im having following two textBlocks 在我的XAML中,我有以下两个textBlocks
<TextBlock Name="tbGeneratedSignature" TextWrapping="Wrap" Margin="2,2,0,0" Height="auto" Width="390" Foreground="Black" TextDecorations="None" VerticalAlignment="Top" Focusable="False"/>
<TextBlock Name="tbSignatureText" TextWrapping="Wrap" Margin="5" Height="auto" Width="440" Foreground="Black" />
On the basis of tbGeneratedSignature.Text i want to assign the same value to tbSignatureText.Text using XAML only rather than using C#. 在tbGeneratedSignature.Text的基础上,我想使用XAML而不是使用C#为tbSignatureText.Text分配相同的值。
have you considered binding? 你考虑过绑定吗?
<TextBlock Name="tbSignatureText"
Text="{Binding ElementName=tbGeneratedSignature, Path=Text, UpdateSourceTrigger=PropertyChanged}"
TextWrapping="Wrap"
Margin="5"
Height="auto"
Width="440"
Foreground="Black" />
<TextBlock Name="tbGeneratedSignature" TextWrapping="Wrap" Margin="2,2,0,0" Height="auto" Width="390" Foreground="Black" TextDecorations="None" VerticalAlignment="Top" Focusable="False"/>
<TextBlock Name="tbSignatureText" Text="{Binding ElementName=tbGeneratedSignature, Path=Text}" TextWrapping="Wrap" Margin="5" Height="auto" Width="440" Foreground="Black" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.