【问题标题】:ItemsControl items do not render in ScrollViewer in Windows Phone appItemsControl 项目不在 Windows Phone 应用程序的 ScrollViewer 中呈现
【发布时间】:2013-02-02 14:05:18
【问题描述】:

我正在尝试在 Windows Phone 应用程序中创建滚动页面。此页面有一些静态内容,后跟项目的 ItemsControl。

<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">            
  <ScrollViewer>
    <Grid>
      <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition Height="Auto" />
        <RowDefinition />
      </Grid.RowDefinitions>

      <TextBlock Text="Static text line 1" />
      <TextBlock Grid.Row="1" Text="Another lineof static text" />

      <ItemsControl Grid.Row="2" ItemsSource="{Binding Path=MyItems}" ItemTemplate="{StaticResource myTemplate}"></ItemsControl>
    </Grid>
  </ScrollViewer>
</Grid>

奇怪的是,当我使用这种方法时,ItemsControl 项目不会呈现。但是,如果我将 ScrollViewer 移动到静态文本项下方,并将 ItemsControl 放置在 ScrollViewer 中,我的项目就会呈现得很好。

我做错了什么?我觉得必须有一些我忽略的小而微不足道的东西。谢谢。

【问题讨论】:

  • 第一个 TextBlockItemsControl 将在同一个网格行中,这意味着一个会覆盖另一个,但我认为这是 TextBlock 你不会看不见。
  • 我错过了 Grid.Row 的定义。它现在在那里。我同意你的评估。不过,我的项目没有显示。

标签: c# windows-phone


【解决方案1】:

&lt;RowDefinition /&gt; 行替换为&lt;RowDefinition Height="*" /&gt;。 * 表示它将占用所有可用空间。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-12-28
    • 2012-03-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-14
    • 1970-01-01
    相关资源
    最近更新 更多