How to get control reference that register routed event
I have an application with NavBar(WPF TreeView) and TabControl. Tab items
contain DataGrid and search TextBox in the top. I want to handle Ctrl+F
key independently which control is focused(NavBar, Menu and etc.) and
focus search-box of active tab control.
I define a global command, and KeyGasture for window, and from my control
I register to that command using this code
var commandBinding = new CommandBinding(MyCommands.FindRowCommand, (s, e) =>
{
//How to get my search TextBox hear?
}, (s, e) => e.CanExecute = true);
CommandManager.RegisterClassCommandBinding(typeof(Window), commandBinding);
The question is, that I need search box reference inside the
CommandBinding action, how can I get my SearchBox inside it? Note that
there might be a lot of TextBoxes, so I think looking logical tree for
TextBox is not a case.
No comments:
Post a Comment