2016-11-08 6 views
0

各チームのプレーヤーが停止している状態で、水平に進むチームのコレクションを表示したいとします。これを達成するために、ListView(lvwTeams)がチームのコレクションにバインドされています。私はlvwTeams.ItemsPanelを方向をHorizo​​ntalに設定してStackPanelに変更します。 ItemTemplateは、TeamのPlayersコレクションにバインドされた別のListView(lvwPlayers)を含むように変更されます。ListView.ItemsPanelのStackPanelを使用したアラインメントの問題

すべて動作しますが、ItemTemplateで定義されたコントロールはStackPanelの中​​央に表示されます。 lblTeamNameを最上部に配置する方法はありますか?lvwPlayersはこの下にありますが、StackPanelによって与えられた残りの領域を埋める方法はありますか?任意の助けを事前に

<ListView x:Name="lvwTeams" Grid.Row="1" Grid.Column="1" ItemsSource="{Binding Teams}"> 
    <ListView.ItemsPanel> 
     <ItemsPanelTemplate> 
      <StackPanel Orientation="Horizontal"></StackPanel> 
     </ItemsPanelTemplate> 
    </ListView.ItemsPanel> 

    <ListView.ItemTemplate> 
     <DataTemplate> 
      <Grid> 
       <Grid.RowDefinitions> 
        <RowDefinition Height="Auto"/> 
        <RowDefinition Height="Auto"/> 
       </Grid.RowDefinitions> 
       <Label x:Name="lblTeamName" Grid.Row="0" Content="{Binding Name}"/> 
       <ListView x:Name="lvwPlayers" Grid.Row="1" ItemsSource="{Binding Players}" > 
        <ListView.ItemTemplate> 
         <DataTemplate> 
          <Label Content="{Binding FullName}"/> 
         </DataTemplate> 
        </ListView.ItemTemplate> 

       </ListView> 
      </Grid> 

     </DataTemplate> 
    </ListView.ItemTemplate> 
</ListView> 

感謝:

はここでXAMLです。

答えて

1

はこのように、リストビューの内容にストレッチを入れてみてください:

 <ListView x:Name="lvwTeams" 
       Grid.Row="1" 
       Grid.Column="1" 
       ItemsSource="{Binding Teams}" 
       HorizontalContentAlignment="Stretch" 
       VerticalContentAlignment="Stretch"> 

そして第二に、リストビューを伸ばすために、グリッドの2列目*を置きます。

<ListView.ItemTemplate> 
    <DataTemplate> 
     <Grid> 
      <Grid.RowDefinitions> 
       <RowDefinition Height="Auto"/> 
       <RowDefinition Height="*"/> 
      </Grid.RowDefinitions> 
+0

こんにちはルプシルヴィア、それは素晴らしい作品です!ありがとう! – Cleve

+0

@Cleve。聞いてうれしいです。それが大丈夫なら、答えとしてマークすることもできます。 –

+0

なんらかの理由で私は答えとしてそれをマークするために4分待たなければならなかったので、遅れていました。 – Cleve

関連する問題