<UserControl x:Class="BeWo.View.VarFieldView" 
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
             xmlns:localView="clr-namespace:BeWo.View" 
             Height="Auto" Width="Auto" HorizontalAlignment="Stretch" 
             VerticalAlignment="Stretch" Focusable="True" xmlns:localcore="clr-namespace:BeWo.Core" >
    <Grid>
		<ItemsControl Name="lv_root" ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.HorizontalScrollBarVisibility="Disabled">
			<ItemsControl.ItemsPanel>
				<ItemsPanelTemplate>
					<WrapPanel Orientation="Horizontal" />
				</ItemsPanelTemplate>
			</ItemsControl.ItemsPanel>
			<ItemsControl.ItemTemplate>
				<DataTemplate>
					<GroupBox Margin="3" x:Name="GROUPBOX" Header="{Binding Key.GroupName}" VerticalAlignment="Top" Style="{StaticResource ObjectEditGroupBox}">
						<Grid>
							<ItemsControl ItemsSource="{Binding Value}">
								<ItemsControl.ItemsPanel>
									<ItemsPanelTemplate>
										<Grid Grid.IsSharedSizeScope="True" localcore:BeWoWpfUtils.AutoHeightRowCount="{Binding Key.RowCount}" localcore:BeWoWpfUtils.AutoWidthColumnCount="{Binding Key.ColumnCount}" />
									</ItemsPanelTemplate>
								</ItemsControl.ItemsPanel>
								<ItemsControl.ItemTemplate>
									<DataTemplate>
										<localView:VarFieldEditControl VarFieldVM="{Binding}" />
									</DataTemplate>
								</ItemsControl.ItemTemplate>
								<ItemsControl.ItemContainerStyle>
									<Style TargetType="{x:Type ContentPresenter}">
										<Setter Property="Grid.Row" Value="{Binding YCoordinate}" />
										<Setter Property="Grid.Column" Value="{Binding XCoordinate}" />
										<Setter Property="Grid.RowSpan" Value="{Binding RowSpan}" />
										<Setter Property="Grid.ColumnSpan" Value="{Binding ColumnSpan}" />
									</Style>
								</ItemsControl.ItemContainerStyle>
							</ItemsControl>
						</Grid>
					</GroupBox>
				</DataTemplate>
			</ItemsControl.ItemTemplate>
		</ItemsControl>
	</Grid>
</UserControl>