【问题标题】:How to always position a control to a fixed location on screen in silverlight on wp7?如何在 wp7 的 Silverlight 中始终将控件定位到屏幕上的固定位置?
【发布时间】:2012-01-05 08:36:04
【问题描述】:

无论客户端将焦点更改到哪个文本框,我如何始终将 Silverlight 控件放置在屏幕上的同一位置?基本上我有一个我希望始终可见的标题横幅。当客户端将焦点更改为文本框时,我希望所有内容滚动以使文本框进入中心视图(这是默认行为),但应始终显示在 (0,0) 屏幕坐标处的横幅除外.到目前为止,我对布局的了解是:

<Grid x:Name="LayoutRoot"
      Background="Transparent">

    <Grid.RowDefinitions>
        <RowDefinition Height="80" />
        <RowDefinition Height="*" />
        <RowDefinition Height="Auto" />
    </Grid.RowDefinitions>

    <TextBlock Name="myBanner"
               VerticalAlignment="Top"
               HorizontalAlignment="Left"
               Height="80"
               Width="480" />

    <TextBox Grid.Row="2"
             Name="textBox1"
             Text="TextBox"
             VerticalAlignment="Top"
             HorizontalAlignment="Left"
             Height="72"
             Width="480"
             />                  <--- Even when client focuses on this I want myBanner to be visible at (0,0) screen coordinate
</Grid>

这方面的一个例子可以在手机上的短信应用中看到。无论客户是否专注于编写文本框,顶部的标题“John Doe,文本”始终出现在同一位置。

再次感谢您的帮助。

【问题讨论】:

    标签: silverlight xaml windows-phone-7


    【解决方案1】:

    试试这个

      <Grid>
         <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
    
            <RowDefinition />
         </Grid.RowDefinitions>
         <!-- Your banner goes here-->
         <TextBlock Text="some text" />
         <ScrollViewer Grid.Row="1">
             <!-- Your content goes here-->
         </ScrollViewer>
    
      </Grid>
    

    【讨论】:

    • 感谢您的回复,但这并不能完全解决问题。你有 如果我插入一个 并聚焦到它,则横幅不再可见,因为当键盘输入时整个屏幕已经向上滚动。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-05-12
    • 1970-01-01
    • 2012-01-15
    • 1970-01-01
    • 2011-11-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多