0

我有以下问题:

<DataTemplate x:Key="OrganisationsItemTemplate">
            <StackPanel VerticalAlignment="Top" Margin="5,0,0,0">
                <Button Command="{Binding Path=DataContext.LoadSpacesCommand, ElementName=OrganisationList}" CommandParameter="{Binding}" Padding="-5,0,-5,-5" Margin="-7,-12,-7,-7" Height="auto" BorderThickness="0" HorizontalAlignment="Left" VerticalAlignment="Stretch" HorizontalContentAlignment="Left" UseLayoutRounding="True" FontSize="0.01">
                    <Grid Margin="0,0,5,0">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="67"/>
                            <ColumnDefinition/>
                        </Grid.ColumnDefinitions>
                        <StackPanel Grid.Column="0" Background="Transparent">
                            <Border Background="White" BorderThickness="0" Width="62" Height="62" HorizontalAlignment="Left" Margin="0,0,0,5">
                                <Image Source="{Binding image.thumbnail_link}" Width="62" Height="62"></Image>
                            </Border>
                        </StackPanel>
                        <StackPanel Grid.Column="1" VerticalAlignment="Center" Background="Transparent">
                            <!--<TextBlock Text="{Binding name}" HorizontalAlignment="Left" FontSize="30" VerticalAlignment="Center" Margin="0,0,0,5" />-->
                            <phone:LongListSelector x:Name="SpacesList"
                                        Background="Transparent"
                                        ItemTemplate="{StaticResource SpacesTemplate }" 
                                        ItemsSource="{Binding spaces}" 
                                        Margin="40,0,0,96" 
                                        LayoutMode="List"
                                        HideEmptyGroups="True"
                                        IsGroupingEnabled="False" VerticalContentAlignment="Top">
                            </phone:LongListSelector>
                        </StackPanel>
                    </Grid>
                </Button>
            </StackPanel>
        </DataTemplate>
        <DataTemplate x:Key="SpacesTemplate">
            <Border Background="Transparent" Padding="5,0,0,5">
                <Border Background="{StaticResource PhoneAccentBrush}" BorderBrush="{StaticResource PhoneAccentBrush}" BorderThickness="2" Width="62" 
         Height="62" Margin="0,0,18,0" HorizontalAlignment="Left">
                    <TextBlock Text="{Binding name}" Foreground="{StaticResource PhoneForegroundBrush}" FontSize="48" Padding="6" 
            FontFamily="{StaticResource PhoneFontFamilySemiLight}" HorizontalAlignment="Left" VerticalAlignment="Center"/>
                </Border>
            </Border>
        </DataTemplate>

在我的数据模板中,我放置了 LongListselector... 这也需要一个模板。但看不到当前数据模板之外定义的 SpacesTemplate。任何想法如何从数据模板“OrganisationsItemTemplate”中引用数据模板“SpacesTemplate”

4

1 回答 1

1

Xaml是自上而下阅读的,如果你想在SpacesTemplate里面使用,OrganisationsItemTemplate你必须把SpacesTemplatebeforeOrganisationsItemTemplateXaml

于 2013-10-17T23:15:53.220 回答