wp7 listbox bouncing - 列表底部的项目

时间:2011-02-12 10:45:44

标签: silverlight windows-phone-7

我注意到列表框中的最后一项不会自由向上滚动。当我试图将它们移动时,它们几乎“反弹”。当我激活SIP时效果更差。我无法在屏幕上滚动底部项目。它们停留在屏幕的底部,我看不到它们(或者它们被部分阻挡)。

有关如何纠正这种情况的任何想法?

    <ListBox VerticalAlignment="Top">
        <Grid>

            <TextBox Height="72" Margin="109,10,0,0" HorizontalAlignment="Left" Name="txt1" Text=""  VerticalAlignment="Top" TextWrapping="Wrap" Width="341" InputScope="Text"/>
            <TextBox Height="72" Margin="109,70,267,0" HorizontalAlignment="Left" Name="txt2" Text="0" VerticalAlignment="Top" Width="80" InputScope="Number" />
            <TextBox Height="72" Margin="0,70,73,0" HorizontalAlignment="Right" Name="txt3" Text="0" VerticalAlignment="Top" Width="80" InputScope="Number"/>
            <TextBox Height="131" Margin="12,160,0,0" HorizontalAlignment="Left"  Name="txt4" Text="" VerticalAlignment="Top" TextWrapping="Wrap" Width="438" InputScope="Text"/>
            <TextBox Height="72" Margin="12,320,0,147" HorizontalAlignment="Left" Name="txt5" Text=""  VerticalAlignment="Top" Width="438" InputScope="Text"/>


            <TextBlock Height="30" Margin="47,30,333,0" Name="lbl1" Text="Dosage" VerticalAlignment="Top" />
            <TextBlock Height="30" Margin="10,90,332,0" Name="lbl2" Text="Quantity" VerticalAlignment="Top" />
            <TextBlock Height="30" Margin="0,90,142,0" Name="lbl3" Text="Refills" VerticalAlignment="Top" HorizontalAlignment="Right"/>
            <TextBlock Height="37" Margin="24,135,212,0" Name="lbl4" Text="Additional Instructions" VerticalAlignment="Top" />
            <TextBlock Height="30" Margin="24,293,0,0" Name="lbl5" Text="Reason for Taking" HorizontalAlignment="Left" VerticalAlignment="Top" />
            <TextBlock Height="30" Margin="24,385,0,0" Name="lbl6" Text="Consumption Frequency:" HorizontalAlignment="Left"  VerticalAlignment="Top"/>


            <TextBlock FontWeight="Bold" Height="30" HorizontalAlignment="Left" Margin="27,417,0,0" Name="lblday1" Text="Sun" VerticalAlignment="Top" Width="37" />
            <TextBlock FontWeight="Bold" Height="30" HorizontalAlignment="Left" Margin="83,417,0,0" Name="lblday2" Text="Mon" VerticalAlignment="Top" Width="46" />
            <TextBlock FontWeight="Bold" Height="30" HorizontalAlignment="Right" Margin="0,417,272,0" Name="lblday3" Text="Tue" VerticalAlignment="Top" Width="37" />
            <TextBlock FontWeight="Bold" Height="30" HorizontalAlignment="Left" Margin="203,417,0,0" Name="lblday4" Text="Wed" VerticalAlignment="Top" Width="46" />
            <TextBlock FontWeight="Bold" Height="30" HorizontalAlignment="Left" Margin="263,417,0,0" Name="lblday5" Text="Thur" VerticalAlignment="Top" Width="46" />
            <TextBlock FontWeight="Bold" Height="30" HorizontalAlignment="Left" Margin="329,417,0,0" Name="lblday6" Text="Fri" VerticalAlignment="Top" Width="37" />
            <TextBlock FontWeight="Bold" Height="30" HorizontalAlignment="Left" Margin="388,417,0,0" Name="lblday7" Text="Sat" VerticalAlignment="Top" Width="37" />


            <CheckBox Content="CheckBox" Height="72" HorizontalAlignment="Left" Margin="15,431,0,0" Name="chkSun" VerticalAlignment="Top" VerticalContentAlignment="Top" Width="59" />
            <CheckBox Content="CheckBox" Height="72" HorizontalAlignment="Left" Margin="75,431,0,0" Name="chkMon" VerticalAlignment="Top" VerticalContentAlignment="Top" Width="59" />
            <CheckBox Content="CheckBox" Height="72" HorizontalAlignment="Left" Margin="135,431,0,0" Name="chkTue" VerticalAlignment="Top" VerticalContentAlignment="Top" Width="59" />
            <CheckBox Content="CheckBox" Height="72" HorizontalAlignment="Right" Margin="0,431,202,0" Name="chkWed" VerticalAlignment="Top" VerticalContentAlignment="Top" Width="59" />
            <CheckBox Content="CheckBox" Height="72" HorizontalAlignment="Left" Margin="255,431,0,0" Name="chkThu" VerticalAlignment="Top" VerticalContentAlignment="Top" Width="59" />
            <CheckBox Content="CheckBox" Height="72" HorizontalAlignment="Left" Margin="315,431,0,0" Name="chkFri" VerticalAlignment="Top" VerticalContentAlignment="Top" Width="59" />
            <CheckBox Content="CheckBox" Height="72" HorizontalAlignment="Left" Margin="375,431,0,0" Name="chkSat" VerticalAlignment="Top" VerticalContentAlignment="Top" Width="59" />

        </Grid>
    </ListBox>     

更新

好的,我回答了自己的问题。至少我找到了自己问题的初步答案。我所做的纠正弹跳的方法是修改。

中的height属性
<Grid Height="800">

现在,当SIP处于活动状态时,底部项目可见,并且有足够的空间。 正如我上面所说,我找到了答案。我不知道这是不是正确的答案。如果你有更好的方法,请告诉我。

当我测试时,是的,当SIP处于活动状态时,我可以自由地移动到底部。然而,当我移动尝试向后移动时,我再次获得弹跳效果。有什么东西我需要添加,以允许它自由上下移动?

2 个答案:

答案 0 :(得分:6)

问题一般是Listbox不知道它有多高。你可以通过在它的父级上设置一个显式高度来解决它。更好的方法是在网格中为它定义一行:

<Grid>
  <Grid.RowDefinitions>
    <RowDefinition Height="*"/>  
  </Grid.RowDefinitions>
  <ListBox Grid.Row="0">
    ...
  </ListBox>
</Grid>

高度=“*”表示该行应占用其容器的整个空间。

答案 1 :(得分:0)

好的,我回答了自己的问题。至少我找到了自己问题的答案。我所做的纠正弹跳的方法是修改。

中的height属性
<Grid Height="800">

现在,当SIP处于活动状态时,底部项目可见,并有足够的空间。

正如我上面所说,我找到了答案。我不知道这是不是正确的答案。如果你有更好的方法,请告诉我。