How to make a clickable pick list and redirect to a new page in a Windows Phone project?

advertisements

I have a Listbox in my Windows Phone page, that contains some text among other things. I want each grouped item to be clickable and taken to the same destination page, but passing a different parameter each time. This is the closest approximation to what I want right now:

        <ListBox Margin="0,0,-12,0" Name="MainListBox" ItemsSource="{Binding Items}">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Button Width="460" Height="220" ClickMode="Release" Click="Button_Click" Tag="{Binding Name1}" BorderThickness="0" >
                        <Button.Content>
                            <StackPanel Orientation="Horizontal" Margin="0,0,0,17" >
                                <Border Background="#FFE5001b" BorderBrush="Black" BorderThickness="2" Height="100" Width="100" Margin="12,0,9,0"  >
                                    <TextBlock Text="{Binding Name2, Mode=TwoWay}" TextWrapping="Wrap" Margin="12,-28,9,0" Style="{StaticResource PhoneTextSubtleStyle}" FontSize="40" Name="Name2" />
                                </Border>
                                <StackPanel Width="311">
                                    <TextBlock Text="{Binding Name1, Mode=TwoWay}" TextWrapping="Wrap" Style="{StaticResource PhoneTextExtraLargeStyle}" FontStretch="Condensed" />
                                    <TextBlock Text="{Binding Name3, Mode=TwoWay}" TextWrapping="Wrap" Margin="12,-6,12,0" Style="{StaticResource PhoneTextSubtleStyle}"/>
                                    <TextBlock Text="{Binding Name4, Mode=TwoWay}" TextWrapping="Wrap" Margin="12,-6,12,0" Style="{StaticResource PhoneTextSubtleStyle}"/>
                                    <TextBlock Text="{Binding Calories, Mode=TwoWay}" TextWrapping="Wrap" Margin="12,-6,12,0" Style="{StaticResource PhoneTextSubtleStyle}"/>
                                </StackPanel>
                            </StackPanel>
                        </Button.Content>
                    </Button>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>

The problem is that the click is set to Release (if set to Press, I cannot scroll at all). Everytime I try to scroll up/down, I get the momentary white glow associated with the click of a button. How do I do this correctly? I don't mind not using the button, just want this to work :/


Check this out. In the selection changed event handler you can decide which page to navigate based on which item was selected.
And no need for the button inside the template.