【发布时间】:2023-03-21 22:55:02
【问题描述】:
当我进入 ListBox 控件时,第一个项目获得焦点。当我有一个标签并将目标属性设置为 ListBox(如下面的代码所示)然后使用专用的 Alt 快捷方式时,它将关注的不是第一项而是列表框本身(列表框边框变成虚线)。避免这种不良行为的最佳方法是什么?有没有办法禁用对列表框本身的关注而只允许关注项目?
示例代码:
<Label Content="_Label" Margin="0,10,0,88" Name="MyLabel" Target="{Binding ElementName=MyListBox}" Height="Auto" /> <ListBox Width="100" Name="MyListBox" Margin="46,0,639,0" />
行为:
【问题讨论】:
-
When I have a label and set the target property to the listbox- 这到底是什么意思?你能发布代码以使其更清晰。 -
@RohitVats 添加了示例代码