我是 C#/XAML 编码的新手,我有以下问题。
我有这个 ListView 并且我已将附加模板添加到生成的项目中
<ListView x:Name="lvItems" HorizontalAlignment="Left" Height="251" Margin="10,42,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.5,0.5" Width="1346" SelectionChanged="lvItems_SelectionChanged" Foreground="{x:Null}" ItemTemplate="{StaticResource Standard500x130ItemTemplate}">
如果我去编辑模板,我会得到以下代码
<!-- Grid-appropriate 500 by 130 pixel item template as seen in the GroupDetailPage -->
<DataTemplate x:Key="Standard500x130ItemTemplate">
<Grid Height="110"
Width="480"
Margin="10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Border Background="{StaticResource ListViewItemPlaceholderBackgroundThemeBrush}"
Width="110"
Height="110">
<Image Source="{Binding Image}"
Stretch="UniformToFill"
AutomationProperties.Name="{Binding Title}" />
</Border>
<StackPanel Grid.Column="1"
VerticalAlignment="Top"
Margin="10,0,0,0">
<TextBlock Text="{Binding Title}"
Style="{StaticResource TitleTextStyle}"
TextWrapping="NoWrap" />
<TextBlock Text="{Binding Subtitle}"
Style="{StaticResource CaptionTextStyle}"
TextWrapping="NoWrap" />
<TextBlock Text="{Binding Description}"
Style="{StaticResource BodyTextStyle}"
MaxHeight="60" />
</StackPanel>
</Grid>
</DataTemplate>
现在我想访问 Texblocks Title、Subtitle、Description 来添加我从 XML 文件中解析的数据。我想我需要访问每个 TextBlock 的绑定,但我不知道该怎么做。你能帮助我吗?
在此先感谢您的帮助