2015-10-08 39 views
0

我试图做一个块,其中包含我想要在滚动查看器中实现的新闻。 该块应该看起来像这样:Windows Phone - 新闻块

  • 图片在右上角的分辨率(分辨率:50 * 50);
  • 文字与图片一起包裹;

    <ScrollViewer Grid.Row="1" x:Name="ContentRoot" Margin="20,0,20,0"> 
        <StackPanel> 
         <Button Width="Auto" Height="150"> 
          /*Text and picture here like described before*/ 
         </Button> 
         <Button Width="Auto" Height="150"> 
          /*Text and picture here like described before*/ 
         </Button> 
        </StackPanel> 
    </ScrollViewer> 
    

PS:我想只设计它,而不是试图使功能应用。

+0

有一个视觉例子吗? –

+0

有点像Android应用报刊亭: http://www.androidos.in/wp-content/uploads/2014/04/google-newsstand.png 当消息块按钮。 –

回答

1

你可以只使用GridColumnDefinitionsButton内部,例如:

<Button Width="Auto" 
        Height="50" 
        HorizontalContentAlignment="Stretch"> 
       <Grid Height="50"> 
        <Grid.ColumnDefinitions> 
         <ColumnDefinition /> 
         <ColumnDefinition Width="Auto" /> 
        </Grid.ColumnDefinitions> 

        <TextBlock Text="Sample text - lorem ipsum dolor sit amet" 
           TextWrapping="Wrap" 
           TextAlignment="Left" 
           VerticalAlignment="Top" 
           Margin="12"/> 

        <Image Grid.Column="1" 
          Source="SampleImageSourceHere" 
          HorizontalAlignment="Right" 
          Width="50" /> 
       </Grid> 
      </Button> 

注:这只是样品,我没有测试它,但你可以尝试调整您的视角。希望能帮助到你。

此外,如果您将大量项目(按钮)添加到列表中,我建议使用ListView。 ListView支持virtualizaton并避免内存问题。

如果您有源项目集合,则可以使用项目模板创建ListView并设置ItemsSource。我在这里找到关于它的线索:Windows Phone ListView Binding