使用Silverlight2dataGrid例子(完整XAML)
-
<data:DataGrid x:Name="results" RowHeight="60" IsReadOnly="True" Width="800" Margin="14"
-
RowBackground="#99FFFFFF" AlternatingRowBackground="#66FFFFFF"
-
HeadersVisibility="None" GridlinesVisibility="Horizontal"
-
RowDetailsVisibility="VisibleWhenSelected" SelectionMode="SingleFullRow">
-
<data:DataGrid.Columns>
-
<data:DataGridTemplateColumn Width="80">
-
<data:DataGridTemplateColumn.CellTemplate>
-
<DataTemplate>
-
<Border CornerRadius="5" BorderThickness="1" Margin="5" BorderBrush="DarkGray" Background="Black">
-
<Image Source="{Binding ImageUrl}" Stretch="UniformToFill" Margin="1"/>
-
</Border>
-
</DataTemplate>
-
</data:DataGridTemplateColumn.CellTemplate>
-
</data:DataGridTemplateColumn>
-
-
<data:DataGridTextBoxColumn displayMemberBinding="{Binding Title}" FontSize="20" FontWeight="Bold" Width="527"/>
-
-
<data:DataGridTemplateColumn Width="165">
-
<data:DataGridTemplateColumn.CellTemplate>
-
<DataTemplate>
-
<StackPanel VerticalAlignment="Center">
-
<TextBlock Text="Source" Foreground="#666666" FontWeight="Bold" FontFamily="Trebuchet MS" FontSize="14"/>
-
<TextBlock Text="{Binding Source}" FontFamily="Trebuchet MS" FontSize="14"/>
-
</StackPanel>
-
</DataTemplate>
-
</data:DataGridTemplateColumn.CellTemplate>
-
</data:DataGridTemplateColumn>
-
</data:DataGrid.Columns>
-
-
<data:DataGrid.RowDetailstemplate>
-
<DataTemplate>
-
-
<Grid Margin="5,5,0" Background="Transparent">
-
<Grid.ColumnDeFinitions>
-
<ColumnDeFinition />
-
<ColumnDeFinition Width="Auto"/>
-
</Grid.ColumnDeFinitions>
-
-
<Grid.RowDeFinitions>
-
<RowDeFinition Height="Auto"/>
-
<RowDeFinition Height="10" />
-
</Grid.RowDeFinitions>
-
-
<StackPanel>
-
<TextBlock Text="{Binding Description}" textwrapping="Wrap" Margin="5" FontFamily="Trebuchet MS" FontSize="16"/>
-
<TextBlock Text="Posted On:" Foreground="#666666" Margin="5,0" FontFamily="Trebuchet MS" FontSize="14" FontWeight="Bold"/>
-
<TextBlock Text="{Binding PublishDate}" Margin="5,5" FontFamily="Trebuchet MS" FontSize="14"/>
-
<TextBlock Text="View Count:" Foreground="#666666" Margin="5,0" FontFamily="Trebuchet MS" FontSize="14" FontWeight="Bold"/>
-
<TextBlock Text="{Binding ViewCount}" Margin="5,5" FontFamily="Trebuchet MS" FontSize="14"/>
-
</StackPanel>
-
<Border Grid.Column="1" Height="330" Width="440" CornerRadius="5" BorderThickness="1" Margin="5" BorderBrush="DarkGray" Background="Black" VerticalAlignment="Top">
-
<Grid>
-
<MediaElement Margin="2" Source="{Binding VideoUrl}" Autoplay="True"/>
-
<Button Content="Play" Width="50" Height="50" Margin="0,35" Opacity="0"/>
-
</Grid>
-
</Border>
-
</Grid>
-
</DataTemplate>
-
</data:DataGrid.RowDetailstemplate>
-
</data:DataGrid>