2015-10-08 108 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