Focus is completely lost with Teaching tip
See original GitHub issueI am using the Teaching Tip control in a UWP app. However, I am not able to get focus on the teaching tip. As suggested in the documentation, pressing F6 does not help. The focus is completely lost and I am not able to navigate using the tab key even in the rest of the app. The only option is to press the Esc key which dismisses the teaching tip.
The reason I suspect this happens is because the “IsLightDismissEnabled” property is set to True, hence there is no cross button on the top right corner. Moreover, I do not use the “ActionButton” or the “CloseButton”. If I have any of those, then the focus gets set on pressing F6. I have my own custom content in the Teaching tip -
<muxc:TeachingTip
x:Name="TestTip"
Title="Sample Title"
Target="{x:Bind TaskEntryBar.PlusIcon}"
PreferredPlacement="TopRight"
IsLightDismissEnabled="True">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="2 of 2" FontSize="14"/>
<Button
x:Name="TestButton"
Grid.Column="1"
FontSize="14"
Margin="6,0"
Content="Got it"
Click="AddTaskTip_Click" />
</Grid>
</muxc:TeachingTip>
As suggested in one of the other issues, I tried to set the focus ( in the code behind file ) on my custom button but that also did not work -
TestTip.IsOpen = true;
TestButton.Focus(FocusState.Programmatic);
And using the visual tree helper, I got the popup, but Focus() method is not available on a popup.
var popups = VisualTreeHelper.GetOpenPopups(Window.Current);
foreach (var popup in popups)
{
popup.Focus(FocusState.Programmatic);
}
Please suggest what can I do to get focus on the teaching tip in case of only custom content and with IsLightDismissEnabled set to true.
Windows 10 Version: Build 19041.450 Device Form Factor: Desktop
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (8 by maintainers)
Top GitHub Comments
Definitely should be added to the TeachingTip’s main documentation page then. Can open a PR for that later today.
This is especially problematic in a WinUI app for the TextBox controls since is causes the user to have to click the TextBox twice.
The only way I know to get around this is to setup a PropertyChangedCallback for the teaching tip…
teachingTip.RegisterPropertyChangedCallback(TeachingTip.IsOpenProperty, IsTipOpenChanged);
Then inside the callback shift the focus back to the TextBox.