2016-12-13 10 views
0

"スケジュール"というListCollectionViewにバインドするListBoxがあります。日によってListBoxをデータと同じ行にグループ化する

<ListBox Grid.Row="2" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ItemsSource="{Binding Schedules}"> 
    <ListBox.GroupStyle> 
     <GroupStyle> 
      <GroupStyle.HeaderTemplate> 
       <DataTemplate> 
        <TextBlock Text="{Binding Name}" /> 
       </DataTemplate> 
      </GroupStyle.HeaderTemplate> 
     </GroupStyle> 
    </ListBox.GroupStyle> 
    <ListBox.ItemTemplate> 
     <DataTemplate> 
      <StackPanel Background="Transparent"> 
       <Grid Background="Transparent"> 
        <Grid.ColumnDefinitions> 
         <ColumnDefinition Width="100"/> 
         <ColumnDefinition Width="100"/> 
         <ColumnDefinition/> 
        </Grid.ColumnDefinitions> 
        <Grid.RowDefinitions> 
         <RowDefinition/> 
        </Grid.RowDefinitions> 
        <!--I want my DateTime Grouping Here basically--> 
        <!--<TextBlock Grid.Column="0" Grid.Row="0" Text="{Binding MyDateTime}" HorizontalAlignment="Left" VerticalAlignment="Center"/>--> 
        <TextBlock Grid.Column="1" Grid.Row="0" Text="{Binding MyDateTime, StringFormat='t'}" HorizontalAlignment="Left" VerticalAlignment="Center"/> 
        <TextBlock Grid.Column="2" Grid.Row="0" Text="{Binding SomeText}" TextTrimming="WordEllipsis" LineStackingStrategy="MaxHeight" MaxHeight="20" HorizontalAlignment="Left" VerticalAlignment="Center"/> 
       </Grid> 
      </StackPanel> 
     </DataTemplate> 
    </ListBox.ItemTemplate> 
</ListBox> 

そして、私のviewmodel Iグループそれの唯一の(私は戻って日付だけを私に与えValueConverterを使用します。

Schedules.GroupDescriptions.Add(new PropertyGroupDescription("MyDateTime", new DateTimeToDateOnlyConverter())); 

は、それがグループ分けをすることは可能ですが、同じに表示します他のデータとしてライン 今、あなたはあなたが得る場合があります?

MyDateTime
-----------------時間| Sometext
----- ------------時間| Sometext
-----------------時間| Sometext
MyDateTime2
-----------------時間|私はそれがこのように表示したいSometext

MyDateTime |時間| Sometext
                                          |時間| Sometext
                                          |時間| Sometext
MyDateTime |時間| Sometext
                                          |時間| Sometext
                                          |時間| Sometext

答えて

0

は、行

<TextBlock Grid.Column="0" Grid.Row="0" Grid.RowSpan="2" Text="{Binding MyDateTime}" HorizontalAlignment="Left" VerticalAlignment="Center"/>

をマージするためにあなたのXAMLにgrid.rowspanを追加します
関連する問題