<UserControl x:Class="BeWo.View.VarFieldEditControl" 
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
             xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid" 
             xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core" 
             xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors" 
             xmlns:shared="clr-namespace:BS.Shared;assembly=BS.Shared"
             xmlns:localcore="clr-namespace:BeWo.Core" HorizontalAlignment="Stretch" VerticalAlignment="Top">

	<UserControl.Resources>

        <dxe:DateEdit MaskType="DateTimeAdvancingCaret" VerticalAlignment="Top" Margin="3" x:Key="{x:Static shared:ControlType.DatePicker}" EditValue="{Binding VarFieldValue, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" Grid.Column="1" AllowNullInput="True" />
        <CheckBox Foreground="Black" Margin="3,6,3,3" x:Key="{x:Static shared:ControlType.CheckBox}" IsThreeState="False" IsChecked="{Binding VarFieldValueBoolean}" Grid.Column="1" />
        <TextBox Foreground="Black" Margin="3" x:Key="{x:Static shared:ControlType.TextBox}" Text="{Binding VarFieldValue, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" Grid.Column="1" Height="{Binding Height, Mode=OneWay}" VerticalContentAlignment="Center"/>
        <TextBox Foreground="Black" Margin="3" x:Key="{x:Static shared:ControlType.MemoBox}" Text="{Binding VarFieldValue, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" Height="{Binding Height, Mode=OneWay}" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Hidden" TextWrapping="Wrap" AcceptsReturn="True" AutoWordSelection="True" Grid.Column="1" />
        <dxe:TextEdit MaskType="Numeric" Mask="########0.00" MaskUseAsDisplayFormat="True" x:Name="tb_numeric" Margin="3" x:Key="{x:Static shared:ControlType.NumericTextBox}" EditValue="{Binding VarFieldValue}" Height="{Binding Height, Mode=OneWay}" Grid.Column="1" />
        <ComboBox Foreground="Black" Margin="3" x:Key="{x:Static shared:ControlType.ComboBox}" ItemsSource="{Binding PossibleItems}" SelectedItem="{Binding VarFieldValue}" Grid.Column="1" />

        <ListBox Foreground="Black" Margin="3" x:Key="{x:Static shared:ControlType.CheckBoxList}" ItemsSource="{Binding PossibleItems}" SelectionMode="Multiple" Grid.Column="1" Height="{Binding Height, Mode=OneWay}" localcore:BeWoWpfUtils.SelectedItemsList="{Binding VarFieldValue}">
			<ListBox.Resources>
				<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent" />
				<SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="Transparent" />
				<Style TargetType="ListBoxItem">
					<Setter Property="Background" Value="Transparent" />
				</Style>
			</ListBox.Resources>
			<ListBox.ItemsPanel>
				<ItemsPanelTemplate>
					<WrapPanel Orientation="Vertical" MaxHeight="{Binding ElementName=ItemsControlScroller, Path=ActualHeight}" />
				</ItemsPanelTemplate>
			</ListBox.ItemsPanel>
			<ListBox.ItemTemplate>
				<DataTemplate>
					<DockPanel Margin="4,0,4,0">
						<CheckBox IsChecked="{Binding RelativeSource={RelativeSource AncestorType={x:Type ListBoxItem}}, Path=IsSelected, Mode=TwoWay}" VerticalAlignment="Center" />
						<Label Content="{Binding}" />
					</DockPanel>
				</DataTemplate>
			</ListBox.ItemTemplate>
		</ListBox>
	</UserControl.Resources>

	<Grid Grid.Column="{Binding XCoordinate}" HorizontalAlignment="Stretch" VerticalAlignment="Top" x:Name="grid_root" Grid.Row="{Binding YCoordinate}">
		<Grid.ColumnDefinitions>
			<ColumnDefinition SharedSizeGroup="{Binding XCoordinate,StringFormat=lblCol{0}}" Width="Auto" />
			<ColumnDefinition Width="*" />
		</Grid.ColumnDefinitions>
		<TextBlock Foreground="Black" Text="{Binding Label}" Margin="3 6 3 3" />
	</Grid>

</UserControl>