C# 如何将值列表从一个数据模板传递到另一个数据模板?

C# 如何将值列表从一个数据模板传递到另一个数据模板?,c#,xaml,windows-8,microsoft-metro,C#,Xaml,Windows 8,Microsoft Metro,我有一个字符串值(或标记)列表,我想在另一个DataTemplate中创建一个DataTemplate。例如,假设我有一个包含字符串、int和字符串列表的对象。字符串列表是我感兴趣的标记集。对于每个标记,我都有一个要使用的特定数据模板: <!-- This is the Tag Template--> <DataTemplate x:Name="TagTemplate"> <Border Background="LightGray">

我有一个字符串值(或标记)列表,我想在另一个DataTemplate中创建一个DataTemplate。例如,假设我有一个包含字符串、int和字符串列表的对象。字符串列表是我感兴趣的标记集。对于每个标记,我都有一个要使用的特定数据模板:

<!-- This is the Tag Template-->
<DataTemplate x:Name="TagTemplate">
    <Border Background="LightGray">
        <TextBlock Text="{Binding TagValue}"/> <!-- This is where I'm not sure how to reference the individual tag-->
    </Border>
</DataTemplate>

另一个DataTemplate的主体将包含如下标记:

<!-- This is the main Data Template for the overall data-->
<DataTemplate>
     <Grid>
          <GridView ItemsSource="{Binding Tags}" ItemTemplate="{StaticResource TagTemplate }"/>
          <!-- Below is a commented static representation of the tags-->
          <!--<TextBlock Text="TAG, TAG, TAG, TAG, TAG" Margin="5, 5, 5, 5"/>-->
     </Grid>
<DataTemplate>

标记的数据绑定将是一个字符串列表
list Tags


我的问题是,我不确定如何引用第二个绑定,或者甚至不确定是否可以从一个
DataTemplate
向另一个传递任何内容的列表。这是可能的,如果是,如何实现?

如果您的标签集合是
列表
,那么在
日期模板
中,
数据上下文
将是实际项目:因此,给定的
字符串
,您可以使用以下语法绑定到当前的
数据上下文

<DataTemplate x:Name="TagTemplate">
    <Border Background="LightGray">
        <TextBlock Text="{Binding}"/>
    </Border>
</DataTemplate>