Question

I am trying to figure out how to have two columns of different binded data on one page. The left column for sounds the right for a save ringtone task for each sound. I can't put two longlistselectors on one page, it wont let me.

Using a sample, its easy to see how to used binded data for the sound. And the great thing is you only have to enter new code into the binded items and it automatically populates each page with new sound tiles.

Id like to add a save ringtone tile that would essentially work the same way. But it would only make sense if I can get the save ringtone tiles next to the sound tiles on the same page.

Is there any way to do this? All I really need to know, I think, is how to get two columns of different data bindings onto the same page, hopefully in a longlistselector so it will scroll.

Here is a sample of the code im using now.


<phone:PhoneApplicationPage.Resources>    
    <DataTemplate x:Key="SoundTileDataTemplate">
    <Grid Background="{StaticResource PhoneAccentBrush}"
        Margin="0,0,135,0">
        <Grid VerticalAlignment="Top"
            HorizontalAlignment="right"
            Width="40"
            Height="40"
            Margin="0, 6, 6, 0">
            <Ellipse Stroke="{StaticResource PhoneForegroundBrush}"
                StrokeThickness="3"/>
            <Image Source="/Assets/AppBar/Play.png" />
        </Grid>
        <StackPanel VerticalAlignment="bottom">
            <TextBlock Text="{Binding Title}" 
                Margin="6,0,0,6"/>
        </StackPanel>
    </Grid>
    </DataTemplate>
</phone:PhoneApplicationPage.Resources>

<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
    <!--Pivot Control-->
    <phone:Pivot Title="{Binding Path=LocalizedResources.ApplicationTitle, 
        Source={StaticResource LocalizedStrings}}">
        <!--Pivot item one-->
        <phone:PivotItem Header="{Binding Animals.Title}">
            <!--Double line list with text wrapping-->
            <phone:LongListSelector Margin="0,0,-12,0" 
                ItemsSource="{Binding Animals.Items}"
                LayoutMode="List"
                ItemTemplate="{StaticResource SoundTileDataTemplate}"
                SelectionChanged="LongListSelector_SelectionChanged">
           </phone:LongListSelector>
        </phone:PivotItem>
    </phone:Pivot>
</Grid>
Was it helpful?

Solution

Easy solution.

     <DataTemplate x:Key="NewItemTemplate">
        <StackPanel HorizontalAlignment="Left" Orientation="Horizontal" >
            <StackPanel Orientation="Horizontal" Width="56">
                <CheckBox x:Name="CheckBox1" HorizontalAlignment="Left" IsChecked="{Binding Checked, Mode=TwoWay}" BorderBrush="Black" Style="{StaticResource CheckBoxStyleGrey1}" Width="90" Height="74" />
            </StackPanel>
            <StackPanel Orientation="Horizontal" RenderTransformOrigin="0.5,0.5" Width="803" >
                <StackPanel.RenderTransform>
                    <CompositeTransform ScaleX="-1"/>
                </StackPanel.RenderTransform>
                <TextBlock Text="{Binding lItem}" Foreground="Black" FontSize="45" Margin="-176,0,0,0" RenderTransformOrigin="0.5,0.5">
                    <TextBlock.RenderTransform>
                        <CompositeTransform ScaleX="-1"/>
                    </TextBlock.RenderTransform>
                </TextBlock>
                <TextBlock Text="{Binding lCategory}" Foreground="Black" Margin="-146,0,-2,0" RenderTransformOrigin="0.5,0.5" >
                    <TextBlock.RenderTransform>
                        <CompositeTransform ScaleX="-1"/>
                    </TextBlock.RenderTransform>
                </TextBlock>
            </StackPanel>

        </StackPanel>
    </DataTemplate>

Edit the ItemTemplate based on your needs, and you might have to play around with it in blend if there is an error. In Blend, go to your long list selector and edit the item template.

OTHER TIPS

First of all, by aiming to add 2 long list selectors next to each other, you are approaching to this problem from a very wrong perspective. That's bad for the user, bad for UX, bad for the sake of UI design and bad for the unicorns.

You are trying to associate a functionality (Save ringtone) within another LongListSelector, to the corresponding Item in another Long List Selector. What an earth made you think that adding another Long List Selector and populating it with many Save Ringtone buttons is going to solve your problem? For a second, let's say you somehow achieve adding two Long List Selectors next to each other and deployed your items on the left selector and save ringtone buttons on the right. How you are planning to correctly associate them when they are scrolled? User will scroll the left one and the right Long List Selector will remain static.

You shouldn't add one more Long List Selector to your front. Instead you should go and modify your ItemTemplate in one Long List Selector. Then you will be able to have more than one tile, button, text or whatever you need for one single LongListSelector Item.

ItemTemplate="{StaticResource SoundTileDataTemplate}"

I am not going to submit a solution to add more than one button/tile/text for one LongListSelector item and associate their communication/functionality. Because there are already some 5 million example on the internet about this.

I highly recommend reading Design Guidelines for Windows Phone for you. Because you have such ideas that will result as one more crappy app on the Store. People really got enough of crappy apps. So please either completely stop developing apps for Windows Phone or give a break to whatever you are doing now and go read the design principles.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top