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