The purpose of Getting the XamlRoot
is to move the focusable element inside CalenderView
. To move the focus we need to get the current focused element FocusManager.GetFocusedElement()
which requires XamlRoot
for WinUI3. So, How to get the XamlRoot
of the CalenderView
?. If not, is there any better way to manipulate the focus within CalenderView
This one doesn't work as XamlRoot returns the CalenderDatePicker's frame.
private void CalendarDatePicker_Opened(object sender, object e)
{
FocusManager.TryMoveFocus(FocusNavigationDirection.Previous, new FindNextElementOptions() { SearchRoot = (FocusManager.GetFocusedElement((sender as FrameworkElement).XamlRoot) as FrameworkElement) });
}
Exception for the above code is "Value doesn't fall in expected range"