Avalonia
Avalonia copied to clipboard
FocusManager initialization should be handled by Locator
Is your feature request related to a problem? Please describe.
Currently FocusManager
is created and bound by Application.RegisterServices
, thus ignoring anything already bound to locator at the level of IWindowingPlatform
or upper. Thus we have to inherit Application
and override RegisterServices
to be able to set custom FocusManager
.
Describe the solution you'd like
I think FocusManager shoudl be registered at platform initialization level and only consumed by Application
.
Describe alternatives you've considered
As described upper we could create our inheritor of Application
, but then we need to duplicate initialization parts of it
Additional context
May be there are some restrictions based on dependency order, thus may be it makes sense to consider to extract additional entities/splitting FocusManager
to several parts if necessary.
- same for
KeyboardNavigationHandler
I think you actually can replace IKeyboardNavigationHandler with a locator. Consolonia did it https://github.com/jinek/Consolonia/pull/79/files#diff-87edd463c680c3814584dca5b6b1069eea554e8f412169d00db01865270f0066R23
Not sure if there is a reason to replace FocusManager. Replacing keyboard handler should be enough for custom navigation.
I think you actually can replace IKeyboardNavigationHandler with a locator.
Whatever we set to locator it is then overridden by Avalonia's Application
https://github.com/AvaloniaUI/Avalonia/blob/master/src/Avalonia.Controls/Application.cs#L234
As a hack we need to create our own application and re-register the value in the locator one more time.
You can register it after Application did it?
You can register it after Application did it?
Yes, as I said we need to inherit our own Application
class and re-register the instance. Which means we can not just use regular Application