相关疑难解决方法(0)

将焦点设置在ListBox项上会破坏键盘导航

以编程方式选择ListBox项后,需要按下\ up键两次以移动选择.有什么建议?

视图:

<ListBox Name="lbActions" Canvas.Left="10" Canvas.Top="10"
               Width="260" Height="180">
        <ListBoxItem Name="Open" IsSelected="true" Content="Open"></ListBoxItem>
        <ListBoxItem Name="Enter" Content="Enter"></ListBoxItem>
        <ListBoxItem Name="Print" Content="Print"></ListBoxItem>
</ListBox>
Run Code Online (Sandbox Code Playgroud)

码:

public View()
{
   lbActions.Focus();
   lbActions.SelectedIndex = 0; //not helps
   ((ListBoxItem) lbActions.SelectedItem).Focus(); //not helps either
}
Run Code Online (Sandbox Code Playgroud)

wpf select listview listbox listboxitem

9
推荐指数
1
解决办法
1万
查看次数

标签 统计

listbox ×1

listboxitem ×1

listview ×1

select ×1

wpf ×1