简体   繁体   English

wp7列表框弹起-列表底部的项目

[英]wp7 listbox bouncing - items at bottom of list

I've noticed that the last items in my list box don't scroll up freely. 我注意到列表框中的最后一项没有自由滚动。 They almost "bounce" when I try to move them up. 当我尝试将它们向上移动时,它们几乎“弹跳”。 The effect is even worse when I have the SIP active. 当我启用SIP时,效果甚至更糟。 I can't scroll the bottom items up the screen. 我无法在屏幕上滚动底部的项目。 They stay on the bottom of the screen and I can't see them (or they are partially blocked). 它们停留在屏幕的底部,我看不到它们(或者它们被部分遮挡了)。

Any ideas on how to correct this situation? 关于如何纠正这种情况的任何想法?

    <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>     

UPDATE: 更新:

OK, I sort of answered my own question. 好吧,我已经回答了我自己的问题。 At least I found an initial answer to my own question. 至少我找到了自己问题的初步答案。 What I did to correct the bouncing is to modify the height property in the . 我所做的纠正弹跳的操作是修改中的height属性。

<Grid Height="800">

Now when the SIP is active the bottom items are visible with plenty of room to spare. 现在,当SIP处于活动状态时,可以看到底部的项目,并有足够的余地。 As I said above, I found an answer. 正如我上面所说,我找到了答案。 I don't know if it was the right answer. 我不知道这是否是正确的答案。 If you have a better way, please let me know. 如果您有更好的方法,请告诉我。

When I was testing this, yes, when the SIP is active I can initially move freely to the bottom. 是的,当我对此进行测试时,当SIP处于活动状态时,我可以首先自由移动至底部。 However, when I move try to move back up I get the bounce effect again. 但是,当我尝试向后移动时,会再次获得反弹效果。 Is there something that I need to add to allow it to move freely up and down? 我需要添加一些内容以使其自由上下移动吗?

The problem in general is that the Listbox doesn't know how tall it is. 通常的问题是,列表框不知道它有多高。 You can solve it by setting an explicit height on it's parent, sure. 当然,您可以通过在其父级上设置显式高度来解决该问题。 A better way to do it would be to define a row for it in the grid: 更好的方法是在网格中为其定义一行:

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

The Height="*" says the row should take the entire space of it's container. Height =“ *”表示该行应占据其容器的整个空间。

OK, I answered my own question. 好,我回答了我自己的问题。 At least I found an answer to my own question. 至少我找到了自己问题的答案。 What I did to correct the bouncing is to modify the height property in the . 我所做的纠正弹跳的操作是修改中的height属性。

<Grid Height="800">

Now when the SIP is active the bottom items are visible with plenty of room to spare. 现在,当SIP处于活动状态时,可以看到底部的项目,并有足够的余地。

As I said above, I found an answer. 正如我上面所说,我找到了答案。 I don't know if it was the right answer. 我不知道这是否是正确的答案。 If you have a better way, please let me know. 如果您有更好的方法,请告诉我。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM