0
votes

i created an app to track tweets and binding it to listBox.

and, here is the xaml of the listBox:

           <ListBox Margin="0,0,-12,0" x:Name="listBox1" ItemsSource="{Binding Items}" SelectionChanged="listBox1_SelectionChanged">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal" Margin="0,0,0,17">
                            <!--Replace rectangle with image-->
                            <Image Height="100" Width="100" Source="{Binding DeveloperImage}" Margin="12,0,9,0"/>
                            <StackPanel Width="311">
                                <TextBlock Text="{Binding DeveloperName}" TextWrapping="Wrap" Style="{StaticResource PhoneTextExtraLargeStyle}"/>
                                <TextBlock Text="{Binding DeveloperBirthday}" TextWrapping="Wrap" Margin="12,-6,12,0" Style="{StaticResource PhoneTextSubtleStyle}"/>
                            </StackPanel>
                        </StackPanel>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>

but, when it was debugged, it returned into this sequence:

long blank content blank

what i want is:

content only, no blanks befor the content and no blanks after the content.

1
Could you show the enclosing element (Grid?) and perhaps a picture of what you get and what you would like to get? - Emond Erno
i would like to get the clean listbox, no blanks between the beginning and ending of the listBox - user1072976
You will have to adjust the Templates of the ListBox for that. - Emond Erno
adjusting like what? can you explain it @ answers section? - user1072976
There are lots of peole here who could help you if you just explain what you want. Making a screenshot like Erno suggests can be done within a minute... - Jan Slodicka

1 Answers

0
votes

The way a ListBox arranges its Children is determined by its ItemsPanel.

You can replace the default ItemsPanel by setting the ItemsPanelTemplate.

Each Child is then wrapped in an ItemContainer.

You can replace the default ItemContainer by setting the ItemContainerStyle.

Finally, the ListBox itself has a border, padding and margin that influence where the ItemsPanel is placed.

So if you want to adjust the placement of the content of the listbox you will first have to find out what template(s) should be modified. A quick way is to use Blend because it will give you visual feedback.