Я хотел бы создать ItemsControl
, где дочерние элементы помещаются как WrapPanel
, но дочерние элементы должны занимать столько места, сколько могут. Так что, когда размер окна становится больше или меньше, дочерние элементы должны растягиваться в соответствии с определенным соотношением ширины и высоты. Когда дочерние элементы добавляются или удаляются из ItemsControl
ItemsSource
, WrapPanel
должен помещать линейные разрывы между элементами соответствующим образом, чтобы сохранить соотношение между элементами: ширина по высоте.
Ниже я до сих пор. Можно ли это сделать в Xaml? или я должен создать для этого настраиваемый элемент управления? Спасибо заранее!
<Window>
<Grid>
<ItemsControl ItemsSource="{Binding DataCollection}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Vertical"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border BorderBrush="Black" BorderThickness="1" HorizontalAlignment="Stretch">
<StackPanel Orientation="Horizontal" >
<TextBlock TextWrapping="Wrap" Text="{Binding Name}" />
<TextBlock TextWrapping="Wrap" Text="{Binding Value}"/>
<TextBlock TextWrapping="Wrap" Text="{Binding Time, StringFormat='hh:mm:ss' }"/>
</StackPanel>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
</Window>