简体   繁体   中英

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

 <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#.

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"  />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM