![](/img/trans.png)
[英]WPF : Chainging another control's property in some control's Trigger
[英]Trigger Property on another WPF control event
假設我有一個ListView和TextBox,它們位於同一Window的不同容器中。
在列表視圖中選擇項目我希望根據列表視圖數據綁定的選定項目來更新TextBox Text屬性。 XAML中可能嗎?
好吧...檢查一下
<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<StackPanel>
<ListBox x:Name="lb">
<TextBlock Text="Hey"/>
<TextBlock Text="There"/>
</ListBox>
<TextBlock Text="{Binding SelectedItem.Text, ElementName=lb}"/>
</StackPanel>
</Page>
您可以綁定到SelectedItem。 在這種情況下,我在作弊,因為我知道它是一個TextBlock,但在現實世界中,您將不得不編寫DataTemplate(最有可能)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.