Click here to Skip to main content
15,902,447 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a list view that is being filled with a list. when i put a messagebox to tell me count of the list view it is giving me the correct answer so the listview is being filled, but nothing is displayed.

this is the code of the binding.

XML
<ListView  ItemsSource="{Binding UsageProfilesList}" Grid.Row="1"   HorizontalAlignment="Stretch" x:Name="usageProfileLists123" >
                    <ListView.ItemTemplate>
                          <DataTemplate>
                              <Border Margin="0,10,0,10" PreviewMouseLeftButtonDown="StartDragging" PreviewMouseMove="Drag" HorizontalAlignment="Stretch"
                                  MouseLeftButtonDown="AddItemToTimeline" Tag="{Binding}" Background="Transparent">
                                  <TextBlock Text="{Binding Name}" FontSize="18" HorizontalAlignment="Center" />
                              </Border>
                          </DataTemplate>
                      </ListView.ItemTemplate>

              </ListView>


and listview123 is being filled. what am i doing wrong?
Posted

Start with something easier and move up. Take a look at:

This..

Use the following ListView:

<listview x:name="lst_Example" xmlns:x="#unknown">
   <listview.view>
      <gridview>
         <gridviewcolumn width="140" header="Column 1" />
      </gridview>
   </listview.view>
</listview>


Then, try the following code to populate it with items from a list:

private void FillMyList()
{
   List<string> theList = new System.Collections.Generic.List<string>();
   theList.Add("Item1");
   theList.Add("Item2");
   theList.Add("Item3");
   theList.Add("Item4");
   theList.Add("Item5");
   theList.Add("Item6");

   foreach (var item in theList)
   {
      lst_Example.Items.Add(item);
   }
}</string></string>
 
Share this answer
 
v7
Comments
UJimbo 29-Jul-11 5:10am    
The new CodeBlock is giving me trouble..
The problem could be from the margin of the BORDER.

XML
<Border Margin="0,10,0,10" PreviewMouseLeftButtonDown="StartDragging" PreviewMouseMove="Drag" HorizontalAlignment="Stretch"
                                  MouseLeftButtonDown="AddItemToTimeline" Tag="{Binding}" Background="Transparent">
                                  <TextBlock Text="{Binding Name}" FontSize="18" HorizontalAlignment="Center" />
                              </Border>


Remove the margin and try.


Mark it as answer if it is helpful
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900