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. WrapPanel / ItemsControl Problem

WrapPanel / ItemsControl Problem

Scheduled Pinned Locked Moved WPF
wpfhelpcsharpcsswcf
4 Posts 2 Posters 38 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.
  • K Offline
    K Offline
    Kevin Marois
    wrote on last edited by
    #1

    I'm trying to use a WrapPanel inside an ItemsControl. I'm following this[^]. The difference is that mine is bound to a list of objects called Backups. Here's what I have. When I run it, I don't see any of the data.

    <Border Grid.Row="1"
    CornerRadius="20"
    Margin="35"
    Padding="10"
    Background="Tan"
    BorderThickness="3"
    BorderBrush="SteelBlue">

    <ScrollViewer VerticalScrollBarVisibility="Auto"
                    Background="Teal"
                    Margin="10">
    
        <ItemsControl ItemsSource="{Binding Backups}">
    
            <ItemsControl.ItemTemplate>
    
                <DataTemplate>
    
                    <Border Background="Salmon"
                            BorderBrush="Blue"
                            BorderThickness="3">
    
                        <StackPanel Orientation="Vertical">
    
                            <Rectangle Margin="5" 
                                        Width="100" 
                                        Height="100" 
                                        Fill="Yellow"
                                        HorizontalAlignment="Center"/>
                            <TextBlock Text="THIS IS A TEST"
                                        HorizontalAlignment="Center"
                                        Margin="5"/>
    
                        </StackPanel>
    
                    </Border>
    
                </DataTemplate>
    
            </ItemsControl.ItemTemplate>
                    
            <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <WrapPanel IsItemsHost="True"/>
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
    
        </ItemsControl>
    
    </ScrollViewer>
    

    </Border>

    In theory, theory and practice are the same. But in practice, they never are.” If it's not broken, fix it until it is. Everything makes sense in someone's mind.

    Richard DeemingR 1 Reply Last reply
    0
    • K Kevin Marois

      I'm trying to use a WrapPanel inside an ItemsControl. I'm following this[^]. The difference is that mine is bound to a list of objects called Backups. Here's what I have. When I run it, I don't see any of the data.

      <Border Grid.Row="1"
      CornerRadius="20"
      Margin="35"
      Padding="10"
      Background="Tan"
      BorderThickness="3"
      BorderBrush="SteelBlue">

      <ScrollViewer VerticalScrollBarVisibility="Auto"
                      Background="Teal"
                      Margin="10">
      
          <ItemsControl ItemsSource="{Binding Backups}">
      
              <ItemsControl.ItemTemplate>
      
                  <DataTemplate>
      
                      <Border Background="Salmon"
                              BorderBrush="Blue"
                              BorderThickness="3">
      
                          <StackPanel Orientation="Vertical">
      
                              <Rectangle Margin="5" 
                                          Width="100" 
                                          Height="100" 
                                          Fill="Yellow"
                                          HorizontalAlignment="Center"/>
                              <TextBlock Text="THIS IS A TEST"
                                          HorizontalAlignment="Center"
                                          Margin="5"/>
      
                          </StackPanel>
      
                      </Border>
      
                  </DataTemplate>
      
              </ItemsControl.ItemTemplate>
                      
              <ItemsControl.ItemsPanel>
                  <ItemsPanelTemplate>
                      <WrapPanel IsItemsHost="True"/>
                  </ItemsPanelTemplate>
              </ItemsControl.ItemsPanel>
      
          </ItemsControl>
      
      </ScrollViewer>
      

      </Border>

      In theory, theory and practice are the same. But in practice, they never are.” If it's not broken, fix it until it is. Everything makes sense in someone's mind.

      Richard DeemingR Offline
      Richard DeemingR Offline
      Richard Deeming
      wrote on last edited by
      #2

      If you remove the ItemsPanel, do you see the items? If not, are there any binding errors logged in the Visual Studio output window?


      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

      K 1 Reply Last reply
      0
      • Richard DeemingR Richard Deeming

        If you remove the ItemsPanel, do you see the items? If not, are there any binding errors logged in the Visual Studio output window?


        "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

        K Offline
        K Offline
        Kevin Marois
        wrote on last edited by
        #3

        I removed the ItemsPanel, and there are no binding errors, yet I still see nothing. Also, I just created a quick test app doing the same thing, and it works: [GitHub - MaroisConsulting/Marois.WrapPanelDemo](https://github.com/MaroisConsulting/Marois.WrapPanelDemo.git)

        In theory, theory and practice are the same. But in practice, they never are.” If it's not broken, fix it until it is. Everything makes sense in someone's mind.

        Richard DeemingR 1 Reply Last reply
        0
        • K Kevin Marois

          I removed the ItemsPanel, and there are no binding errors, yet I still see nothing. Also, I just created a quick test app doing the same thing, and it works: [GitHub - MaroisConsulting/Marois.WrapPanelDemo](https://github.com/MaroisConsulting/Marois.WrapPanelDemo.git)

          In theory, theory and practice are the same. But in practice, they never are.” If it's not broken, fix it until it is. Everything makes sense in someone's mind.

          Richard DeemingR Offline
          Richard DeemingR Offline
          Richard Deeming
          wrote on last edited by
          #4

          Kevin Marois wrote:

          I removed the ItemsPanel, and there are no binding errors, yet I still see nothing.

          Which means the problem is nothing to do with the items panel; either it's not binding to the collection, or the collection is empty.


          "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

          "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

          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