【问题标题】:Windows Phone appBar adding extra margin above keyboardWindows Phone appBar 在键盘上方添加额外的边距
【发布时间】:2012-09-14 12:27:52
【问题描述】:

我正在尝试创建一个消息传递屏幕。这是我的 XAML:

<phone:PhoneApplicationPage
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:edc="clr-namespace:Microsoft.Expression.Controls;assembly=Microsoft.Expression.Drawing" xmlns:em="clr-namespace:Microsoft.Expression.Media;assembly=Microsoft.Expression.Drawing"

mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="696"
x:Class="chatScreen.MainPage"
Orientation="Portrait"
shell:SystemTray.IsVisible="True">

<phone:PhoneApplicationPage.Resources></phone:PhoneApplicationPage.Resources>


<phone:PhoneApplicationPage.ApplicationBar>
    <shell:ApplicationBar>
        <shell:ApplicationBarIconButton IconUri="/icons/appbar.message.send.png" IsEnabled="True" Text="send"/>

</phone:PhoneApplicationPage.ApplicationBar>

<!--LayoutRoot is the root grid where all page content is placed-->


<Grid x:Name="LayoutRoot" Background="Transparent">
    <Grid.RowDefinitions>
      <RowDefinition Height="Auto"/>
      <RowDefinition Height="*"/>
      <RowDefinition Height="auto"/>
    </Grid.RowDefinitions>

    <Grid x:Name="userInfo" Grid.Row="0" Margin="12,0,0,0">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="15" />
            <ColumnDefinition Width="84" />
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="48"/>
        </Grid.ColumnDefinitions>

        <Image x:Name="PresenceIcon" Grid.Column="0"  Height="64" Width="12" HorizontalAlignment="Left" VerticalAlignment="Bottom" Source="available.jpg"  />
        <Image x:Name="DisplayImage" Grid.Column="1"  Height="64" Width="64" HorizontalAlignment="Left" VerticalAlignment="Bottom" Source="tony.jpg"  Margin="0" />

        <Grid x:Name="metaContact_info" Grid.Column="2">
            <Grid.RowDefinitions>
                <RowDefinition Height="*"/>
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>
            <TextBlock x:Name="DisplayName" Grid.Row="0" Text="Tony Stark" TextWrapping="NoWrap" FontSize="40" />
            <TextBlock x:Name="DisplayStatus" Grid.Row="1" Text="enjoying windows phone" FontSize="18" TextTrimming="WordEllipsis" />
        </Grid>
        <Image x:Name="ServiceIcon" Grid.ColumnSpan="2" Grid.Column="3" Source="service_gtalk.jpg" Width="24" Height="24" VerticalAlignment="Top" Margin="0,20,0,0"/>
    </Grid><!-- userInfo ends -->

    <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,18,12,12">
        <Grid.RowDefinitions>
            <RowDefinition Height="auto" />
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <ScrollViewer x:Name="messages" Grid.Row="0" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" Margin="0"/>


    </Grid>
    <ScrollViewer x:Name="inputBox_scroller" Grid.Row="2" Margin="0" MaxHeight="108" VerticalAlignment="Bottom">
        <TextBox x:Name="inputBox"  TextWrapping="Wrap" HorizontalContentAlignment="Stretch" Text="" FontSize="{StaticResource PhoneFontSizeMedium}" InputScope="Chat" AcceptsReturn="True" />
    </ScrollViewer><!-- Content Panel ends -->

我还使用 Jeff Wilcox 的 PhoneThemeManager 1.2 使我的应用程序始终以浅色主题加载。

当我在此屏幕中有 appBar 并且键盘打开时,文本框下方有大约 48 像素的额外边距。当手机主题为黑色时,这会在键盘上方和文本框下方显示一个难看的黑条。当手机主题为白色时,此黑色彩条为白色。为了更好地演示,这里有一些截图:

但是,当我禁用应用栏然后打开键盘时,文本框下方的额外边距不存在。

我想在键盘打开时禁用这个额外的边距,就像它在有 appBar 的消息传递中心中发生的那样,以及键盘的自动更正栏,但仍然没有这个额外的边距。

【问题讨论】:

  • 我已经能够重现您的问题。到目前为止,我不明白为什么会有这个额外的栏,即使在文本框处于焦点时添加负边距也无济于事,因为这个额外的栏出现在布局的前面。奇怪。
  • 我也有这个问题。这个栏的名称是“文本建议栏”,我们可以在这里查看:windowsphone.com/en-us/how-to/wp7/basics/copy-and-paste。我真的很想知道一种方法来覆盖/访问这个栏的方法和字段,疯狂地搜索信息。

标签: windows-phone


【解决方案1】:

唯一的方法(目前已知)是在您键入时禁用 AppBar。

【讨论】:

    【解决方案2】:

    您好,我也遇到了这个问题。将Textbox.InputScope 设置为空会删除键盘上方的额外栏,除了删除 AppBar 之外我无法使其消失。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-05-27
      • 2014-06-25
      • 1970-01-01
      • 2014-08-22
      • 1970-01-01
      • 1970-01-01
      • 2016-06-16
      • 1970-01-01
      相关资源
      最近更新 更多