在Windows应用商店应用项目中,我有以下控件
<ListView x:Name="MyMeetsRow" Grid.Column="0" ItemsSource="{Binding Source={StaticResource cvsActivities}}" Style="{StaticResource MyMeetingsRowUsers}" GroupStyleSelector="{StaticResource listGroupStyleSelector}" />
有这些风格:
<DataTemplate x:Key="MyMeetingUser">
<Grid Margin="0,0,0,10" >
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<StackPanel Height="78" Width="875">
<StackPanel.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0,1" >
<GradientStop Color="#FF0072C6" Offset="0"/>
<GradientStop Color="#FF008FD4" Offset="1"/>
</LinearGradientBrush>
</StackPanel.Background>
<Grid >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="90"/>
<ColumnDefinition Width="65"/>
<ColumnDefinition Width="388"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock x:Name="MyMeetingRowDayNumber" Grid.Column="0" Text="{Binding MyMeetingRowDayNumber}" Style="{StaticResource MyMeetingsRowDay}" />
<Grid Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" x:Name="MyMeetingRowDayText" Text="{Binding MyMeetingRowDayText}" Style="{StaticResource MyMeetingsRowDayText}" Height="28"></TextBlock>
<TextBlock Grid.Row="1" x:Name="MyMeetingRowDayHour" Text="{Binding MyMeetingRowDayHour}" Style="{StaticResource MyMeetingsRowDayHour}" ></TextBlock>
</Grid>
<TextBlock Grid.Column="2" x:Name="MyMeetingsRowTitle" Text="{Binding MyMeetingsRowTitle}" Style="{StaticResource MyMeetingsRowTitle}" />
<!--<ScrollViewer Grid.Column="3" HorizontalScrollBarVisibility="Auto" DataContext="{Binding Item}" VerticalScrollBarVisibility="Disabled" HorizontalScrollMode="Auto" VerticalScrollMode="Disabled">
<GridView DataContext="{Binding Invitees}">
<GridView.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding status}"/>
</DataTemplate>
</GridView.ItemTemplate>
</GridView>
</ScrollViewer>-->
</Grid>
</StackPanel>
</Grid>
</DataTemplate>
<GroupStyle x:Key="listViewGroupStyle">
<GroupStyle.HeaderTemplate>
<DataTemplate>
<Grid Background="#8e8e8e" Width="805" Height="75" Margin="0,0,0,13">
<TextBlock Text='{Binding Key}' Foreground="White" Margin="10,10,0,0" FontFamily="Segoe UI Light" FontSize="55" FontWeight="Light" FontStyle="Normal"/>
</Grid>
</DataTemplate>
</GroupStyle.HeaderTemplate>
</GroupStyle>
<Style x:Key="MyMeetingsRowUsers" TargetType="ListView" >
<Setter Property="HorizontalContentAlignment" Value="Right" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Hidden" />
<Setter Property="Background" Value="Transparent"/>
<Setter Property="TabNavigation" Value="Local"/>
<Setter Property="IsHoldingEnabled" Value="True"/>
<Setter Property="Margin" Value="44,36,0,0" />
<Setter Property="SelectionMode" Value="None" />
<Setter Property="ItemTemplate" Value="{StaticResource MyMeetingUser}" />
<Setter Property="Transitions">
<Setter.Value>
<TransitionCollection>
<EntranceThemeTransition />
</TransitionCollection>
</Setter.Value>
</Setter>
</Style>
和我绑定的项目是这个列表
private ObservableCollection<MeetingRow<Meeting>> myMeet = new ObservableCollection<MeetingRow<Meeting>>();
...
var result = from m in MyMeets group m by m.FullMonth into grp orderby grp.Key select grp;
cvsActivities.Source = result;
对于类Meeting行,它看起来像这样:
public class MeetingRow<T> : BindableBase
{
private T item;
public T Item
{
get { return item; }
set { SetProperty(ref item, value); }
}
private string myMeetingRowDayNumber;
public string MyMeetingRowDayNumber
{
get { return myMeetingRowDayNumber; }
set { SetProperty(ref myMeetingRowDayNumber, value); }
}
private string myMeetingRowDayText;
public string MyMeetingRowDayText
{
get { return myMeetingRowDayText; }
set { SetProperty(ref myMeetingRowDayText, value); }
}
private string myMeetingRowDayHour;
public string MyMeetingRowDayHour
{
get { return myMeetingRowDayHour; }
set { SetProperty(ref myMeetingRowDayHour, value); }
}
private string myMeetingsRowTitle;
public string MyMeetingsRowTitle
{
get { return myMeetingsRowTitle; }
set { SetProperty(ref myMeetingsRowTitle, value); }
}
private string fullMonth;
public string FullMonth
{
get { return fullMonth; }
set { SetProperty(ref fullMonth, value); }
}
}
和我的会议班
public class Meeting
{
public string Id { get; set; }
public string Organizer { get; set; }
public string Organization { get; set; }
public string Name { get; set; }
public string MeetingType { get; set; }
public string Description { get; set; }
public Point Address { get; set; } //X = LAT; Y=LNG
public DateTime StartDate { get; set; }
public DateTime EndTime { get; set; }
public string Status { get; set; }
public List<MeetingPoint> MeetingPoints { get; set; }
public List<MeetingInvitee> Invitees { get; set; }
}
在我填充我的cvsActivities变量以放入ListView ItemSource后,它会正确显示信息,但现在我需要访问cvsActivities列表中每个MeetingRow中Item参数内的List<MeetingInvitee>
来填充评论ScrollViewer中。基本上我想访问父ItemSource上每个项目内的List。
任何想法我怎么能这样做? 感谢。
答案 0 :(得分:0)
您是否只能将listviewitem
从listview
转换为Meeting
对象,然后用它来获取Invitees
?
例如,如果您希望来自selecteditem
的{{1}}:
listview
让我知道是否有任何语法错误我暂时没有做过C#