【问题标题】:Databound listbox not able to scroll windows phone数据绑定列表框无法滚动 windows phone
【发布时间】:2014-04-17 22:23:55
【问题描述】:

我的应用程序中有一个数据绑定列表框和一个列表选择器。我隐藏了列表选择器,只有在触发事件时才会打开。

最初,列表框将填充一些值(超过 10 个值)。我试图滚动列表。但我做不到。当我单击列表并向上拖动鼠标时,列表会进一步向下。效果更像是下拉列表。

xaml 代码如下。请帮忙。

<StackPanel>
<toolkit:ListPicker x:Name="List" ItemsSource="{Binding List_OC}" Visibility="Collapsed" SelectionChanged="List_SelectionChanged">
    <toolkit:ListPicker.FullModeItemTemplate>
         <DataTemplate>
               <TextBlock Text="{Binding NAME}" FontSize="{StaticResource PhoneFontSizeLarge}" />
         </DataTemplate>
    </toolkit:ListPicker.FullModeItemTemplate>
</toolkit:ListPicker>

<ListBox x:Name="Requests1" ItemsSource="{Binding Details_OC}" SelectionChanged="Requests_SelectionChanged">
     <ListBox.ItemTemplate>
          <DataTemplate>
            <Grid HorizontalAlignment="Stretch" Width="450">
              <Grid.RowDefinitions>
                   <RowDefinition Height="auto" />
                   <RowDefinition Height="auto" />
                   <RowDefinition Height="auto" />
              </Grid.RowDefinitions>
              <Grid.ColumnDefinitions>
                   <ColumnDefinition Width="auto" />
                   <ColumnDefinition Width="auto" />
                   <ColumnDefinition Width="auto" />
                   <ColumnDefinition Width="*" />
              </Grid.ColumnDefinitions>
              <CheckBox x:Name="CheckBox1" Grid.Column="0" IsChecked="{Binding Path=IsComplete, Mode=TwoWay}" Grid.RowSpan="3" Checked="CheckBox1_Checked" Unchecked="CheckBox1_Unchecked" />
              <StackPanel Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="4">
                   <TextBlock x:Name="WorkOrderID" HorizontalAlignment="Left" Text="{Binding WORKORDERID}" VerticalAlignment="Top"/>
                   <TextBlock x:Name="date" Text="{Binding Path=DUEBYTIME, Converter={StaticResource dateConverter}}" HorizontalAlignment="Left" VerticalAlignment="Top"/>
              </StackPanel>
              <TextBlock x:Name="Subject" Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="3" HorizontalAlignment="Left" Text="{Binding SUBJECT}" VerticalAlignment="Top" />
              <TextBlock x:Name="Requester" Grid.Row="2" Grid.Column="1" HorizontalAlignment="Left" Text="{Binding REQUESTER}" VerticalAlignment="Top" />
              <TextBlock x:Name="PriorityLabel" Grid.Row="2" Grid.Column="2" HorizontalAlignment="Left" Text=" * Priority : " VerticalAlignment="Top" />
              <TextBlock x:Name="Priority" Grid.Row="2" Grid.Column="3" HorizontalAlignment="Left" Text="{Binding PRIORITY}" VerticalAlignment="Top" />
           </Grid>
         </DataTemplate>
     </ListBox.ItemTemplate>
</ListBox>
</StackPanel>

谢谢。

【问题讨论】:

    标签: data-binding windows-phone-8 listbox


    【解决方案1】:

    我测试了您的代码,并通过将包含您的列表框的 Stackpanel 替换为 Grid 解决了问题。

    它对我有用。

    希望对您有所帮助!

    【讨论】:

    • 谢谢它的工作原理。如果你能说出原因会有所帮助。
    • 我在 stackpanel 上找到了以下信息:" 在 StackPanel 中,将在“面板”中直观地“堆叠”项目。它不包括滚动控件,但您可以使用它轻松呈现有限的项目列表. 它处理一个方向的控件布局。 .所以没有滚动控件...
    • 非常感谢。很有用。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-05-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-09
    • 1970-01-01
    相关资源
    最近更新 更多