How to reference a static resource from within a datatemplate
Asked Answered
M

1

0

I have the following problem:

<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>

In my data template I am placing LongListselector... which also needs a template. but the SpacesTemplate that is defined outside the current datatemplate cannot be seen. any ideas how to reference the datatemplate "SpacesTemplate" from within the datatemplate "OrganisationsItemTemplate"

Mccurdy answered 17/10, 2013 at 22:52 Comment(3)
ahh, my apologies. I think this works fine.. it's actually the fact that the list is leaking the boundaries of the phone.. I wasn't reading the error... or not. does the above look right or wrong? Its hard to tell if it's the error or not?Mccurdy
Xaml is read top down, if you want to use SpacesTemplate inside OrganisationsItemTemplate you will have to put SpacesTemplate before OrganisationsItemTemplate in the XamlDavita
that's the answer. nice one dude. glad didn't delete my question in the end! cool thanks!Mccurdy
D
1

Xaml is read top down, if you want to use SpacesTemplate inside OrganisationsItemTemplate you will have to put SpacesTemplate before OrganisationsItemTemplate in the Xaml

Davita answered 17/10, 2013 at 23:15 Comment(1)
side note, is the drilldown of data okay? if my parent datatemplate is using "Organisations" and accessing a name property inside of it.. if I then in the second LongListSelector put the datasource as spaces... that will be accessing the spaces list inside the Organisations object and that is a list which has "name" property in it. that sounds alright doesn't it... It's just my jump list just seems to flatten out, I guess because it doesn't have data to push the bits down.Mccurdy

© 2022 - 2024 — McMap. All rights reserved.