我注意到列表框中的最后一项没有自由滚动。当我尝试将它们向上移动时,它们几乎“弹跳”。当我启用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处于活动状态时,我可以最初自由移动至底部。但是,当我尝试向后移动时,会再次获得反弹效果。我需要添加一些内容以使其自由上下移动吗?

最佳答案

通常的问题是,列表框不知道它有多高。您可以通过在其父级上设置显式高度来解决它。更好的方法是在网格中为其定义一行:

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


Height =“ *”表示该行应占据其容器的整个空间。

10-04 12:06
查看更多