简体   繁体   中英

Setting focus to input box in an InputDialog using MahApps

We've made our own search dialog based on the InputDialog from MahApps Dialog examples , and it does work, but there are two issues with it:

  1. When opened it does not automatically focus in the search field, so you have to click it before starting to type your search
  2. If possible, we would like to autoselect the first entry in the list, so that you don't need to first select the entry in the list, and then hit the OK button

Can you help with either of these? The first is the most important, as the users start typing quite often before noticing that the focus is not in the search field.

When working with providing some code excerpts to get help, which was basically a copy-and-paste from the example link I provided in the question, I discovered there was a dependency between the class name and the title of the dialog.

<dialogs:BaseMetroDialog x:Class="Some.Path.Dialogs.SearchDialog"
  ...
  d:DesignHeight="500" d:DesignWidth="800" 
  Title="SearchDialog" Background="White">
  ...
</dialogs:BaseMetroDialog>

When the Title matched the last part of Class the focus was set properly. Regarding the auto-select, that turns out not be related to the Metro.MahApps interface, but only internal code, and I found an entry point which sounds promising to get my achieved goal.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM