我正在开发一个提供时间表的应用,如下所示:
但是,我有几个问题:
时间表列表绑定到TimetableHour instaces的ObservableCollection:
public class TimetableHour
{
public sbyte Hour { get; set; }
public IList<TimetableItem> Items { get; set; }
public string HourString
{
get { return Hour.ToString("00") + ":"; }
}
}
和XAML页面:
<Style TargetType="ListView" x:Key="TimetableListViewStyle">
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Hidden" />
<Setter Property="Margin" Value="0,0,60,0" />
<Setter Property="ItemTemplate">
<Setter.Value>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBox Text="{Binding HourString}"
Width="60" Height="50"
TextAlignment="Center"
Background="CornflowerBlue" Foreground="White" BorderThickness="0"
FontSize="23"
Padding="10">
</TextBox>
<GridView ItemsSource="{Binding Items}" Height="Auto" SelectionMode="None" IsTapEnabled="False" IsHoldingEnabled="False" >
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<WrapGrid Orientation="Horizontal" />
</ItemsPanelTemplate>
</GridView.ItemsPanel>
<GridView.ItemTemplate>
<DataTemplate>
<StackPanel Background="LightSkyBlue" Width="60" Height="50">
<TextBlock Text="{Binding Minute}" HorizontalAlignment="Center" FontSize="17" FontWeight="Medium" Margin="0,2,0,0"></TextBlock>
<TextBlock HorizontalAlignment="Center">Tip</TextBlock>
</StackPanel>
</DataTemplate>
</GridView.ItemTemplate>
</GridView>
</StackPanel>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
<ListView Grid.Row="2" Grid.Column="2" ItemsSource="{Binding Timetable}"
Style="{StaticResource TimetableListViewStyle}"
SelectionMode="None" />
答案 0 :(得分:1)
好的,所以我想出来了: