我创建了一个弹出窗口,上面有一些按钮,我无法选择它们,并且XBox默认选择框也不会出现在按钮周围。
<Grid>
<StackPanel HorizontalAlignment="Center" Margin="0,50,0,0">
<Button Content="Show Popup Flyout" Click="ShowFlyoutPopup" />
</StackPanel>
<Popup x:Name="logincontrol1" IsOpen="False" IsLightDismissEnabled="True">
<Popup.ChildTransitions>
<TransitionCollection>
<PaneThemeTransition />
</TransitionCollection>
</Popup.ChildTransitions>
<StackPanel Orientation="Vertical" Background="#313131" Width="1000" Height="500" x:Name="pop" Margin="0,100,0,0" >
<StackPanel>
<GridView ItemsSource="{Binding GamesList}" >
<GridView.ItemTemplate>
<DataTemplate x:Name="testtemp">
<Button x:Name="SwapBtn" Command="{Binding TestClick,Mode=OneWay}">
<StackPanel Width="202" VerticalAlignment="Top">
<Image Source="{Binding ImageUrl}" Height="324"/>
<StackPanel Background="Black" Padding="19,9,0,0">
<TextBlock FontWeight="Semibold" TextTrimming="CharacterEllipsis" FontFamily="Segoe Pro" Foreground="White" TextAlignment="Left" FontSize="24" Text="{Binding Title}" TextWrapping="Wrap" Height="65"/>
<TextBlock FontFamily="Segoe Pro" Foreground="White" TextAlignment="Left" FontSize="16" Text="{Binding Price}" Margin="0,48,0,0"/>
</StackPanel>
</StackPanel>
</Button>
</DataTemplate>
</GridView.ItemTemplate>
</GridView>
</StackPanel>
</StackPanel>
</Popup>
</Grid>
后面的代码:像这样,我无法将重点放在弹出窗口上。我认为它应该自动运行。
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
}
private void ShowFlyoutPopup(object sender, RoutedEventArgs e)
{
if (!logincontrol1.IsOpen)
{
RootPopupBorder.Width = 646;
logincontrol1.HorizontalOffset = Window.Current.Bounds.Width - 1485;
logincontrol1.VerticalOffset = Window.Current.Bounds.Height - 840;
logincontrol1.IsOpen = true;
}
}
}
}
焦点不在弹出窗口中,我无法使用游戏板与之交互。
答案 0 :(得分:0)
您可以将焦点集中在Popup
的其中一个控件上:
logincontrol1.IsOpen = true;
loginclick.Focus(FocusState.Programmatic);