0

在我的 Windows Phone 应用程序中,我的一个页面中有一个带有 Load More 按钮的 ListBox。页面底部有一个文本框和一个按钮。当我单击列表框底部的加载更多按钮时,焦点会自动转到文本框并显示小键盘。我不需要将焦点转到 buttonclick 上的文本框。这个问题是如何发生的,我该如何克服这个问题。

用于列表框的样式的 xaml 如下所示

<phone:PhoneApplicationPage.Resources>
    <Style x:Key="ListBoxMore" TargetType="ListBox">
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}"/>
        <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled"/>
        <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Visible"/>
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="BorderBrush" Value="Transparent"/>
        <Setter Property="Padding" Value="0"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ListBox">
                    <ScrollViewer x:Name="ScrollViewer">
                        <StackPanel>
                        <ItemsPresenter/>
                            <Border BorderBrush="Black" BorderThickness="0,0.5">
                                <Button Content="Load More..." Name="btnLoadMore" Visibility="Visible" Background="White" Foreground="#FF176DDC" Click="btnLoadMore_Click"></Button>
                            </Border>
                        </StackPanel>
                    </ScrollViewer>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</phone:PhoneApplicationPage.Resources>

如下所示的列表框的 xaml

<ListBox x:Name="userDetailsList" SelectionMode="Multiple" Style="{StaticResource ListBoxMore}">
    <ListBox.ItemTemplate>
        <DataTemplate>
            <StackPanel Orientation="Horizontal">
                <Border BorderThickness="0,0.5,0,0" BorderBrush="Black" Width="440">
                    <Grid Width="430">
                        <Image Source="{Binding UserImage}"/>
                        <TextBlock Text="{Binding UserName}"/>
                        <TextBlock Text="{Binding Details}"/>
                        <TextBlock Text="{Binding Date}"/>
                    </Grid>
                </Border>
            </StackPanel>
        </DataTemplate>
    </ListBox.ItemTemplate>
</ListBox>

当我单击 loadmore 按钮时,焦点转到位于列表框下方的文本框。那里只有一个文本框。

4

0 回答 0