<localView:BeWoView x:Class="BeWo.View.Detail.AssessmentSheetCategoryView" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:localView="clr-namespace:BeWo.View" xmlns:localViewModel="clr-namespace:BeWo.ViewModel" xmlns:localViewDetail="clr-namespace:BeWo.View.Detail" xmlns:val="clr-namespace:BeWo.Validation" xmlns:proxy="clr-namespace:BeWo.ServiceProxy" xmlns:uc="clr-namespace:BeWo.Controls;assembly=BeWo.Controls" 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" Height="Auto" Width="Auto" HorizontalAlignment="Stretch" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:r="clr-namespace:BeWo.Security" VerticalAlignment="Stretch" Focusable="True" xmlns:Microsoft_Windows_Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Classic">

	<Grid Grid.IsSharedSizeScope="True">

		<GroupBox x:Name="root" Header="Aktuell erfasste Punktebogen Kategorien" Style="{StaticResource ObjectEditGroupBox}">
			<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch">

				<Grid.ColumnDefinitions>
					<ColumnDefinition Width="Auto" />
					<ColumnDefinition Width="200" />
					<ColumnDefinition Width="Auto" />
					<ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="*" />
				</Grid.ColumnDefinitions>
				<Grid.RowDefinitions>
					<RowDefinition Height="Auto" />
					<RowDefinition Height="Auto" />
					<RowDefinition Height="Auto" />
					<RowDefinition Height="*" />
				</Grid.RowDefinitions>

				<Label Grid.Column="0" Grid.Row="0">Bezeichnung</Label>
				<TextBox Grid.Column="1" Grid.Row="0" Margin="3" HorizontalAlignment="Stretch" VerticalAlignment="Top" Height="23" Text="{val:ValidationBinding Path=NewVM.Description, UpdateSourceTrigger=PropertyChanged}" />

				<Label Grid.Column="2" Grid.Row="0">Position</Label>
                <dxe:SpinEdit EditValue="{Binding Path=NewVM.Position, Converter={StaticResource Int2DecimalConverter}, UpdateSourceTrigger=PropertyChanged}" x:Name="tb_pos" IsFloatValue="False" Increment="1" MinValue="0"  Height="23" Margin="3" Grid.Row="0" Grid.Column="3" AllowNullInput="True" Width="100"/>


				<Label Grid.Column="0" Grid.Row="1">Mögliche Werte</Label>

				<ListView Grid.Column="1" Grid.ColumnSpan="4" Grid.Row="1" Margin="3" Background="Transparent" BorderBrush="Transparent" HorizontalAlignment="Stretch" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ItemsSource="{Binding PossibleValues}">
					<ListView.ItemTemplate>
						<DataTemplate>
							<Grid>
								<Grid.ColumnDefinitions>
									<ColumnDefinition Width="Auto" />
									<ColumnDefinition Width="Auto" SharedSizeGroup="a" />
								</Grid.ColumnDefinitions>
								<dxe:CheckEdit Margin="3" IsChecked="{Binding IsNewSelected}" />
								<TextBlock Margin="3" Grid.Column="1" Text="{Binding Description}" />
							</Grid>
						</DataTemplate>
					</ListView.ItemTemplate>
					<ListView.Resources>
						<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent" />
						<SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="Transparent" />
					</ListView.Resources>
					<ListView.ItemsPanel>
						<ItemsPanelTemplate>
							<WrapPanel />
						</ItemsPanelTemplate>
					</ListView.ItemsPanel>
				</ListView>


				<Button Name="button_addAsc" FontWeight="Normal" HorizontalAlignment="Left" Grid.Column="0" Grid.Row="2" Grid.ColumnSpan="4" Height="25" Margin="3 3 3 3" Padding="5 0" Click="button_addAsc_Click" IsDefault="True">Hinzufügen</Button>


				<dxg:GridControl x:Name="datagrid_asc" Margin="0,10,0,0" Grid.Column="0" Grid.Row="3" Grid.ColumnSpan="5" DataSource="{Binding VMList}">
					<dxg:GridControl.Columns>

						<dxg:GridColumn FieldName="IsDeleteable" Header="" FixedWidth="True" Width="24" ReadOnly="True">
							<dxg:GridColumn.CellTemplate>
								<DataTemplate>
                                    <Button Content="r" Click="DeleteButton_Click" Visibility="{Binding Path=EditValue, Converter={StaticResource BoolVisibilityConverter}}" FontFamily="Webdings" Width="18" Height="18" VerticalAlignment="Center" />
								</DataTemplate>
							</dxg:GridColumn.CellTemplate>
						</dxg:GridColumn>
						<dxg:GridColumn FieldName="Position" Header="Position" Width="50" />
						<dxg:GridColumn FieldName="Description" Header="Bezeichnung" Width="200" />
						<dxg:GridColumn FieldName="ValuesString" Header="Mögliche Werte" Width="500">
							<dxg:GridColumn.DisplayTemplate>
								<ControlTemplate>
									<TextBlock Text="{Binding Value}" TextWrapping="Wrap" />
								</ControlTemplate>
							</dxg:GridColumn.DisplayTemplate>
							<dxg:GridColumn.EditTemplate>
								<ControlTemplate>
									<Button x:Name="PART_Editor" BorderThickness="0" Style="{x:Null}" Height="21" HorizontalAlignment="Stretch" Click="PART_Editor_Click">

										<TextBlock Text="{Binding Value}" TextWrapping="Wrap" />
									</Button>
								</ControlTemplate>
							</dxg:GridColumn.EditTemplate>
						</dxg:GridColumn>
					</dxg:GridControl.Columns>
					<dxg:GridControl.View>
						<dxg:TableView AutoWidth="False" ShowGroupPanel="False" ShowGroupedColumns="False" ShowTotalSummary="False" NavigationStyle="Cell" />
					</dxg:GridControl.View>
				</dxg:GridControl>

				<Popup x:Name="popup_values" Width="400" StaysOpen="false" Placement="MousePoint">
					<Border>
						<Grid Background="White">
							<Grid.RowDefinitions>
								<RowDefinition Height="*" />
								<RowDefinition Height="Auto" />
							</Grid.RowDefinitions>
							<ListView Margin="3" Background="White" BorderBrush="White" HorizontalAlignment="Stretch" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ItemsSource="{Binding PossibleValues}">
								<ListView.ItemTemplate>
									<DataTemplate>
										<Grid>
											<Grid.ColumnDefinitions>
												<ColumnDefinition Width="Auto" />
												<ColumnDefinition Width="Auto" SharedSizeGroup="a" />
											</Grid.ColumnDefinitions>
											<dxe:CheckEdit Margin="3" IsChecked="{Binding IsEditSelected}" />
											<TextBlock Margin="3" Grid.Column="1" Text="{Binding Description}" />
										</Grid>
									</DataTemplate>
								</ListView.ItemTemplate>
								<ListView.Resources>
									<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent" />
									<SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="Transparent" />
								</ListView.Resources>
								<ListView.ItemsPanel>
									<ItemsPanelTemplate>
										<WrapPanel />
									</ItemsPanelTemplate>
								</ListView.ItemsPanel>
							</ListView>
							<Button Name="button_edit" FontWeight="Normal" HorizontalAlignment="Right" Grid.Row="1" Height="25" Margin="3 3 3 3" Padding="5 0" Click="button_edit_Click" IsDefault="True">Übernehmen</Button>
						</Grid>

					</Border>
				</Popup>

			</Grid>
		</GroupBox>
	</Grid>

</localView:BeWoView>