![](/img/trans.png)
[英]Is it correct to have a dependency property value that depend on another property value in WPF?
[英]Updating the value of a TextBlock on the basis of value of another TextBock in WPF using Dependency property
在我的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" />
在tbGeneratedSignature.Text的基礎上,我想使用XAML而不是使用C#為tbSignatureText.Text分配相同的值。
你考慮過綁定嗎?
<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.