页面代码如下:
<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:voteme"
DataContext="{Binding Participants, RelativeSource={RelativeSource Self}}"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:navigation="using:Syncfusion.UI.Xaml.Controls.Navigation"
xmlns:input="using:Syncfusion.UI.Xaml.Controls.Input"
x:Class="voteme.RateAll"
mc:Ignorable="d">
<Grid Style="{StaticResource LayoutRootStyle}">
<Grid.RowDefinitions>
<RowDefinition Height="140"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!-- Back button and page title -->
<Grid Background="#FF939D46">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Button x:Name="backButton" Style="{StaticResource BackButtonLightStyle}" Margin="36"
VerticalAlignment="Top" Click="backButton_Click"/>
<StackPanel>
<TextBlock x:Name="pageTitle" Foreground="White" Grid.Column="1" Text="{StaticResource AppName}"
Style="{StaticResource PageHeaderTextStyle}" Margin="120 38" VerticalAlignment="Top"/>
</StackPanel>
</Grid>
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="300"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid Grid.Column="1" Background="#FFEDEDEB" />
<navigation:SfTabControl TabStripPlacement="Left" Margin="0 60"
Grid.ColumnSpan="2" HorizontalAlignment="Stretch"
x:Name="ParticipantsList"
DisplayMemberPath="FullName">
<navigation:SfTabItem>
<TextBlock Text="{Binding Position}" Style="{StaticResource HeaderTextStyle}" VerticalAlignment="Top"/>
</navigation:SfTabItem>
</navigation:SfTabControl>
</Grid>
</Grid>
类代码(与 TabContent 和 TabItem 相关)是这样的:
public List<ParticipantRatesView> Participants = new List<ParticipantRatesView>();
foreach (var participant in _persons)
{
Participants.Add(
new ParticipantRatesView()
{
FullName = participant.FullName,
Position = participant.Position,
Email = participant.Email,
PersonId = participant.Id,
AverageRate = participant.TotalRate,
OfficeRate = ((Rates) _ratesAll.CurrentItem).OfficeRate,
WindowsRate = ((Rates) _ratesAll.CurrentItem).WindowsRate,
EmoRate = ((Rates) _ratesAll.CurrentItem).EmotionalRate,
CustRate = ((Rates) _ratesAll.CurrentItem).CustomerRate,
RateId = ((Rates) _ratesAll.CurrentItem).Id
});
}
ParticipantsList.ItemsSource = Participants;
这种方式是 Syncfusion 推荐的,但他们根本没有记录 TabItem,标准方式效果不佳。