Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. WPF ListView/Items Control - Another problem

WPF ListView/Items Control - Another problem

Scheduled Pinned Locked Moved WPF
helpcsharpwpfcomhosting
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    snblackout
    wrote on last edited by
    #1

    Hi there, I posted yesterday a problem that I've fixed, but now I ran into another one. This is not a conversion problem, more like a bug. Please do the following in Bea's project to reproduce. 1. Open 'DataSource.cs' 2. Make the 'public Album()' look like below

    public Album()
    {
    this.PicturesLeft = new ObservableCollection();
    this.PicturesRight = new ObservableCollection();

            this.PicturesLeft.Add(new Picture(new Uri("Images\\\\2moons\_2.gif", UriKind.Relative), "Saturn", "Saturn is the most distant of the five planets known to ancient stargazers."));
            this.PicturesLeft.Add(new Picture(new Uri("Images\\\\earglobe.gif", UriKind.Relative), "Earth", "Earth, our home planet, is the only planet in our solar system known to harbor life."));
            this.PicturesLeft.Add(new Picture(new Uri("Images\\\\jupglobe.gif", UriKind.Relative), "Jupiter", "With its numerous moons and several rings, the Jupiter system is a \\"mini-solar system.\\""));
            this.PicturesLeft.Add(new Picture(new Uri("Images\\\\marglobe.gif", UriKind.Relative), "Mars", "The red planet Mars has inspired wild flights of imagination over the centuries."));
            this.PicturesLeft.Add(new Picture(new Uri("Images\\\\merglobe.gif", UriKind.Relative), "Mercury", "The small and rocky planet Mercury is the closest planet to the Sun."));
            this.PicturesLeft.Add(new Picture(new Uri("Images\\\\nepglobe.gif", UriKind.Relative), "Neptune", "Neptune was the first planet located through mathematical predictions."));
            this.PicturesLeft.Add(new Picture(new Uri("Images\\\\plutoch\_2.gif", UriKind.Relative), "Pluto", "Long considered to be the smallest, coldest, and most distant planet from the Sun."));
            this.PicturesLeft.Add(new Picture(new Uri("Images\\\\uraglobe.gif", UriKind.Relative), "Uranus", "Uranus gets its blue-green color from methane gas above the deeper cloud layers."));
            this.PicturesLeft.Add(new Picture(new Uri("Images\\\\venglobe.gif", UriKind.Relative), "Venus", "At first glance, if Earth had a twin, it would be Venus."));
    
            int i;
    
            for (i = 0; i <= 3; i++) 
            {    
                this.PicturesRight.Add(new Picture(new Uri("Images\\\\2moons\_2.gif", UriKind.Relative), "Saturn", "Saturn is the most distant of the five planets known to ancient stargazers."));
                this.PicturesRight.Add(new Picture(new Uri("Images\\\\earglobe.gif", Uri
    
    I 1 Reply Last reply
    0
    • S snblackout

      Hi there, I posted yesterday a problem that I've fixed, but now I ran into another one. This is not a conversion problem, more like a bug. Please do the following in Bea's project to reproduce. 1. Open 'DataSource.cs' 2. Make the 'public Album()' look like below

      public Album()
      {
      this.PicturesLeft = new ObservableCollection();
      this.PicturesRight = new ObservableCollection();

              this.PicturesLeft.Add(new Picture(new Uri("Images\\\\2moons\_2.gif", UriKind.Relative), "Saturn", "Saturn is the most distant of the five planets known to ancient stargazers."));
              this.PicturesLeft.Add(new Picture(new Uri("Images\\\\earglobe.gif", UriKind.Relative), "Earth", "Earth, our home planet, is the only planet in our solar system known to harbor life."));
              this.PicturesLeft.Add(new Picture(new Uri("Images\\\\jupglobe.gif", UriKind.Relative), "Jupiter", "With its numerous moons and several rings, the Jupiter system is a \\"mini-solar system.\\""));
              this.PicturesLeft.Add(new Picture(new Uri("Images\\\\marglobe.gif", UriKind.Relative), "Mars", "The red planet Mars has inspired wild flights of imagination over the centuries."));
              this.PicturesLeft.Add(new Picture(new Uri("Images\\\\merglobe.gif", UriKind.Relative), "Mercury", "The small and rocky planet Mercury is the closest planet to the Sun."));
              this.PicturesLeft.Add(new Picture(new Uri("Images\\\\nepglobe.gif", UriKind.Relative), "Neptune", "Neptune was the first planet located through mathematical predictions."));
              this.PicturesLeft.Add(new Picture(new Uri("Images\\\\plutoch\_2.gif", UriKind.Relative), "Pluto", "Long considered to be the smallest, coldest, and most distant planet from the Sun."));
              this.PicturesLeft.Add(new Picture(new Uri("Images\\\\uraglobe.gif", UriKind.Relative), "Uranus", "Uranus gets its blue-green color from methane gas above the deeper cloud layers."));
              this.PicturesLeft.Add(new Picture(new Uri("Images\\\\venglobe.gif", UriKind.Relative), "Venus", "At first glance, if Earth had a twin, it would be Venus."));
      
              int i;
      
              for (i = 0; i <= 3; i++) 
              {    
                  this.PicturesRight.Add(new Picture(new Uri("Images\\\\2moons\_2.gif", UriKind.Relative), "Saturn", "Saturn is the most distant of the five planets known to ancient stargazers."));
                  this.PicturesRight.Add(new Picture(new Uri("Images\\\\earglobe.gif", Uri
      
      I Offline
      I Offline
      Insincere Dave
      wrote on last edited by
      #2

      Disable item virtualization by adding VirtualizingStackPanel.IsVirtualizing="False" to the ListViews XAML, although if your going too be dealing with 100s of items you might want to look for a different solution.

      S 1 Reply Last reply
      0
      • I Insincere Dave

        Disable item virtualization by adding VirtualizingStackPanel.IsVirtualizing="False" to the ListViews XAML, although if your going too be dealing with 100s of items you might want to look for a different solution.

        S Offline
        S Offline
        snblackout
        wrote on last edited by
        #3

        That did the trick. I have to ask though, why would I need to look for a different solution than the ListView for item counts greater than 100? What is the problem?

        I 1 Reply Last reply
        0
        • S snblackout

          That did the trick. I have to ask though, why would I need to look for a different solution than the ListView for item counts greater than 100? What is the problem?

          I Offline
          I Offline
          Insincere Dave
          wrote on last edited by
          #4

          That piece of code disables item virtualization which improves performance by only creating the items that are visible and regenerating them as you scroll. See MSDN. Heres an altered version of that method that worked with virtualization enabled. It uses a method which was added in .NET 3.5 but Im guessing your using that as otherwise the sample would have probably worked.

          public static FrameworkElement GetItemContainer(ItemsControl itemsControl, Visual bottomMostVisual)
          {
          return itemsControl.ContainerFromElement(bottomMostVisual) as FrameworkElement;
          }

          You can see the effects by trying with and without virtualization if you add more iterations to your loop which adds the pictures. At 200 there was a noticable pause when it was disabled.

          modified on Saturday, January 31, 2009 5:18 PM

          S 1 Reply Last reply
          0
          • I Insincere Dave

            That piece of code disables item virtualization which improves performance by only creating the items that are visible and regenerating them as you scroll. See MSDN. Heres an altered version of that method that worked with virtualization enabled. It uses a method which was added in .NET 3.5 but Im guessing your using that as otherwise the sample would have probably worked.

            public static FrameworkElement GetItemContainer(ItemsControl itemsControl, Visual bottomMostVisual)
            {
            return itemsControl.ContainerFromElement(bottomMostVisual) as FrameworkElement;
            }

            You can see the effects by trying with and without virtualization if you add more iterations to your loop which adds the pictures. At 200 there was a noticable pause when it was disabled.

            modified on Saturday, January 31, 2009 5:18 PM

            S Offline
            S Offline
            snblackout
            wrote on last edited by
            #5

            That worked great, thanks for all your help, I really appreciate it. I'm learning! :laugh:

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups