Question

I am new to using pivot/data template. I thought it would be a good match for listing data of naming different buildings. Now, I want each of those buildings, when clicked on, to each go to a map and show the location of the said building with more information. I'm not sure if it's possible to use the same navigation page, same map control with just different information on it. My app is basically clicking on a building name and it will take me to the next page with a map showing the building via geolocation/geocoordinate and information on the building.

Also, I'm not knowledgeable with what classes or properties to use, if the words fill up to the right of the screen (No Wrap) to have it slide across to see the rest of the content repeatedly.

Here's a screenshot of what I mean: Screenshot Pivot

I've basically use the sample because it automatically lists the items for me but I'm stuck as to how to apply each building to perform a different course of action (with different information and geolocation)

The xaml sample is already provided to bind the list items: (The TextBlock Tap Event is applied to all Binding items within the list, which is not what I want, how can it be different?)

<!--Pivot Control-->
    <phone:Pivot Title="RIT Locator">
        <!--Pivot item one-->
        <phone:PivotItem Header="Building List">
            <!--Double line list with text wrapping-->
            <phone:LongListSelector Margin="0,0,-12,0" ItemsSource="{Binding Items}">
                <phone:LongListSelector.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Margin="0,0,0,17">
                            <TextBlock Tap="TextBlock_Tap" Text="{Binding LineOne}" TextWrapping="NoWrap" Style="{StaticResource PhoneTextExtraLargeStyle}"/>
                            <TextBlock Text="{Binding LineTwo}" TextWrapping="NoWrap" Margin="12,-6,12,0" Style="{StaticResource PhoneTextSubtleStyle}"/>
                        </StackPanel>
                    </DataTemplate>
                </phone:LongListSelector.ItemTemplate>
            </phone:LongListSelector>
        </phone:PivotItem>

        <!--Pivot item two-->
        <phone:PivotItem Header="second">
            <!--Double line list no text wrapping-->
            <phone:LongListSelector Margin="0,0,-12,0" ItemsSource="{Binding Items}">
                <phone:LongListSelector.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Margin="0,0,0,17">
                                <TextBlock Text="{Binding LineOne}" TextWrapping="NoWrap" Margin="12,0,0,0" Style="{StaticResource PhoneTextExtraLargeStyle}"/>
                                <TextBlock Text="{Binding LineThree}" TextWrapping="NoWrap" Margin="12,-6,0,0" Style="{StaticResource PhoneTextSubtleStyle}"/>
                            </StackPanel>
                        </DataTemplate>
                </phone:LongListSelector.ItemTemplate>
            </phone:LongListSelector>
        </phone:PivotItem>
    </phone:Pivot>

C# sample code used to list the items:

public void LoadData()
{
        // Sample data; replace with real data
        this.Items.Add(new ItemViewModel() { LineOne = "Thomas Gosnell Hall", LineTwo = "08 - (GOS)", LineThree = "Science and Mathematics Department" });
        this.Items.Add(new ItemViewModel() { LineOne = "Lyndon Baines Johnson Hall", LineTwo = "060 - (LBJ)", LineThree = "National Technical Institute for the Deaf" });
        this.Items.Add(new ItemViewModel() { LineOne = "Nathaniel Rochester Hall", LineTwo = "043 - (NRH)", LineThree = "Habitant inceptos interdum lobortis nascetur pharetra placerat pulvinar sagittis senectus sociosqu suscipit torquent" });
        this.Items.Add(new ItemViewModel() { LineOne = "Grace Watson Hall", LineTwo = "025 - (GWH)", LineThree = "Ultrices vehicula volutpat maecenas praesent accumsan bibendum dictumst eleifend facilisi faucibus habitant inceptos" });
        this.Items.Add(new ItemViewModel() { LineOne = "Schmitt Interfaith Center", LineTwo = "016 (SMT)", LineThree = "Maecenas praesent accumsan bibendum dictumst eleifend facilisi faucibus habitant inceptos interdum lobortis nascetur" });
        this.Items.Add(new ItemViewModel() { LineOne = "Student Alumni Union", LineTwo = "004 (SAU)", LineThree = "Pharetra placerat pulvinar sagittis senectus sociosqu suscipit torquent ultrices vehicula volutpat maecenas praesent" });
        this.Items.Add(new ItemViewModel() { LineOne = "Monroe Hall", LineTwo = "015 (MON)", LineThree = "Accumsan bibendum dictumst eleifend facilisi faucibus habitant inceptos interdum lobortis nascetur pharetra placerat" });
        this.Items.Add(new ItemViewModel() { LineOne = "Wallace Library", LineTwo = "005 (WAL)", LineThree = "Pulvinar sagittis senectus sociosqu suscipit torquent ultrices vehicula volutpat maecenas praesent accumsan bibendum" });
        this.Items.Add(new ItemViewModel() { LineOne = "Golisano Hall", LineTwo = "070 (GOL)", LineThree = "Facilisi faucibus habitant inceptos interdum lobortis nascetur pharetra placerat pulvinar sagittis senectus sociosqu" });
        this.Items.Add(new ItemViewModel() { LineOne = "Center for Student Innovation", LineTwo = "087 (CSI)", LineThree = "Suscipit torquent ultrices vehicula volutpat maecenas praesent accumsan bibendum dictumst eleifend facilisi faucibus" });
        this.Items.Add(new ItemViewModel() { LineOne = "runtime eleven", LineTwo = "Habitant inceptos interdum lobortis", LineThree = "Habitant inceptos interdum lobortis nascetur pharetra placerat pulvinar sagittis senectus sociosqu suscipit torquent" });
        this.Items.Add(new ItemViewModel() { LineOne = "runtime twelve", LineTwo = "Nascetur pharetra placerat pulvinar", LineThree = "Ultrices vehicula volutpat maecenas praesent accumsan bibendum dictumst eleifend facilisi faucibus habitant inceptos" });
        this.Items.Add(new ItemViewModel() { LineOne = "runtime thirteen", LineTwo = "Maecenas praesent accumsan bibendum", LineThree = "Maecenas praesent accumsan bibendum dictumst eleifend facilisi faucibus habitant inceptos interdum lobortis nascetur" });
        this.Items.Add(new ItemViewModel() { LineOne = "runtime fourteen", LineTwo = "Dictumst eleifend facilisi faucibus", LineThree = "Pharetra placerat pulvinar sagittis senectus sociosqu suscipit torquent ultrices vehicula volutpat maecenas praesent" });
        this.Items.Add(new ItemViewModel() { LineOne = "runtime fifteen", LineTwo = "Habitant inceptos interdum lobortis", LineThree = "Accumsan bibendum dictumst eleifend facilisi faucibus habitant inceptos interdum lobortis nascetur pharetra placerat" });
        this.Items.Add(new ItemViewModel() { LineOne = "runtime sixteen", LineTwo = "Nascetur pharetra placerat pulvinar", LineThree = "Pulvinar sagittis senectus sociosqu suscipit torquent ultrices vehicula volutpat maecenas praesent accumsan bibendum" });

        this.IsDataLoaded = true;
}
Was it helpful?

Solution

That's possible. You can get information about tapped item/building from sender argument of the TextBlock's Tap event handler, then perform action accordingly :

private void TextBlock_Tap(object sender, System.Windows.Input.GestureEventArgs e)
{
    var building = ((TextBlock)sender).Text;
    //perform action based on information about the tapped building 
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top