你确定你点击的额外空白是在你的ListBox
. 你确定你ListBox
的跨度这么大吗?
因为在我的情况下它似乎没有发生....(以下ListBox
是 a 的孩子Window
)
<Window x:Class="WpfApplicationPathToImage.Window4"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window4" Height="100" Width="100">
<ListBox SelectionChanged="ListBox_SelectionChanged">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Text}"/>
</DataTemplate>
</ListBox.ItemTemplate>
<ListBox.ItemsSource>
<x:Array Type="{x:Type TextBlock}">
<TextBlock Text="Text1"/>
<TextBlock Text="Text2"/>
<TextBlock Text="Text3"/>
<TextBlock Text="Text4"/>
<TextBlock Text="Text5"/>
<TextBlock Text="Text6"/>
</x:Array>
</ListBox.ItemsSource>
</ListBox>
</Window>
即使我单击项目级别边界之外的ListBox_SelectionChanged
空白TextBlock
区域(假设我实际上是单击.ListBox