另一个WPF控件事件的触发器属性
假设我有一个列表视图和文本框,它们位于 在同一窗口中的不同容器中 在listview中选择项目我希望更新TextBox文本属性 根据listview数据绑定选定项。 在XAML中可以吗?当然可以。。。看看这个另一个WPF控件事件的触发器属性,wpf,data-binding,xaml,triggers,Wpf,Data Binding,Xaml,Triggers,假设我有一个列表视图和文本框,它们位于 在同一窗口中的不同容器中 在listview中选择项目我希望更新TextBox文本属性 根据listview数据绑定选定项。 在XAML中可以吗?当然可以。。。看看这个 <Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/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。在这种情况下,我是在作弊,因为我知道这是一个文本块,但在现实世界中,你必须编写一个数据模板(最有可能)。谢谢你,我的问题是我无法设置元素名,b/c VS发布错误。