我正在尝试通过使用将列表框中选择的项目放入文本框,Text="{Binding ElementName=list, Path=SelectedItem.Content}"
但文本框只是空白
这是 XAML:
<TextBox x:Name="Mainwindowtext2" HorizontalAlignment="Left" Height="26" Margin="78,132,0,0" TextWrapping="Wrap" Text="{Binding ElementName=list, Path=SelectedItem.Content}" VerticalAlignment="Top" Width="133"/>
<ListBox x:Name="list" HorizontalAlignment="Left" Height="19" Margin="78,74,0,0" VerticalAlignment="Top" Width="133" >
<ListBoxItem Content="1"></ListBoxItem>
<ListBoxItem Content="2"></ListBoxItem>
</ListBox>