<localView:BeWoView x:Class="BeWo.View.Detail.ServiceDescriptionView" 
					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:val="clr-namespace:BeWo.Validation" 
					xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"
                    xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
                    xmlns:Shared="clr-namespace:BS.Shared;assembly=BS.Shared"
                    xmlns:core="clr-namespace:BS.Shared.Core;assembly=BS.Shared"
                    Height="Auto" Width="Auto" HorizontalAlignment="Stretch" 
					VerticalAlignment="Stretch" Focusable="True">
	<GroupBox Name="root" Header="Aktuell definierte Leistungen" Style="{StaticResource ObjectEditGroupBox}">
		<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
			<Grid.ColumnDefinitions>
				<ColumnDefinition Width="400" />
				<ColumnDefinition Width="Auto" />
				<ColumnDefinition Width="*" />
			</Grid.ColumnDefinitions>
			<Grid.RowDefinitions>
				<RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
				<RowDefinition Height="*" />
			</Grid.RowDefinitions>
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <Label Grid.Column="0" Grid.Row="0">Bezeichnung</Label>
                <TextBox Grid.Column="1" Grid.Row="0" Margin="3" Height="23" Text="{val:ValidationBinding Path=NewVM.Name, UpdateSourceTrigger=PropertyChanged}" />
                <Label Grid.Column="2" Grid.Row="0">Kategorie</Label>
                <ComboBox Name="combobox_categories" Grid.Column="3" Grid.Row="0" Height="23" ItemsSource="{Binding Path=PossibleCategories, Mode=OneWay}" Margin="3" SelectedItem="{val:ValidationBinding Path=NewVM.ServiceCategory}">
                    <ComboBox.Resources>
                        <DataTemplate x:Key="DropDownItemTemplate">
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*" />
                                    <ColumnDefinition Width="Auto" />
                                    <ColumnDefinition Width="Auto" />
                                </Grid.ColumnDefinitions>
                                <Label Content="{Binding Path=Name}" />
                                <Label Content="Abrechenbar:" Grid.Column="1" IsEnabled="False" />
                                <CheckBox Grid.Column="2" IsEnabled="False" IsChecked="{Binding Path=IsBillable}" VerticalAlignment="Center" Margin="3 0" />
                            </Grid>
                        </DataTemplate>
                        <DataTemplate x:Key="SelectedItemTemplate">
                            <Label Content="{Binding Path=Name}" Margin="3 0" Padding="0" />
                        </DataTemplate>
                    </ComboBox.Resources>
                    <ComboBox.ItemContainerStyle>
                        <Style>
                            <Setter Property="Control.HorizontalContentAlignment" Value="Stretch" />
                        </Style>
                    </ComboBox.ItemContainerStyle>
                </ComboBox>
                </Grid>

            <Border Grid.Row="0" Grid.Column="1"  Margin="10,3,3,3" BorderThickness="1,0,0,0" BorderBrush="#FF888888" Padding="3,0,0,0">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>
                    <localView:CostRatePeriodControl Grid.ColumnSpan="2" CostRateType="{x:Static Shared:CostRatePeriodType.AmountOfMoney}"
                            VM="{Binding NewVM.CostRatePeriods}" Foreground="#FF000000"
                            ValueLabelText="Betrag (€)"
                            ButtonTooltipText="Neuen Betrag hinzufügen" />

                    <Label Grid.Column="0"
                           Grid.Row="1"
                           Content="Abrechnungsintervall" Margin="3,6,3,0" Padding="0"
                            />
                    <ComboBox x:Name="combo_approvedIntervall"
                              HorizontalAlignment="Stretch"
                            Margin="3" Grid.Row="1"
                            ItemsSource="{x:Static core:EnumTranslations.AccountingInterval2Translations}"
                            SelectedValue="{Binding NewVM.AccountingInterval, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                            SelectedValuePath="Key"
                            DisplayMemberPath="Value"
                            Height="23"
                            Grid.Column="1" />
                </Grid>
            </Border>
			<Button Name="button_addServiceDescription" Click="button_addServiceDescription_Click" Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="2" Height="25" Margin="3,3,3,3" Padding="5 0" IsDefault="True" HorizontalAlignment="Right">Hinzufügen</Button>
			<dxg:GridControl x:Name="datagrid_descriptions" Margin="0,10,0,0" Grid.Column="0" Grid.Row="2" Grid.ColumnSpan="7" DataSource="{Binding VMList}">
				<dxg:GridControl.Columns>
					<dxg:GridColumn FieldName="IsDeleteable" Header="" FixedWidth="True" Width="24" ReadOnly="True">
						<dxg:GridColumn.CellTemplate>
							<DataTemplate>
								<Button Content="r" IsEnabled="{Binding Path=EditValue}" FontFamily="Webdings" Click="DeleteButton_Click" Width="18" Height="18" VerticalAlignment="Center" />
							</DataTemplate>
						</dxg:GridColumn.CellTemplate>
					</dxg:GridColumn>
					<dxg:GridColumn FieldName="Name" Header="Bezeichnung" Width="200" />
					<dxg:GridColumn x:Name="column_category" FieldName="ServiceCategory" Header="Kategorie" Width="200" />
                    <dxg:GridColumn x:Name="column_costrateperiods" FieldName="CurrentAmount.CostRateValue" Header="Betrag" Width="60" EditSettings="{dxe:TextSettings DisplayFormat=c, EditFormat=c}">
                        <dxg:GridColumn.EditTemplate>
                            <ControlTemplate>
                                <Button x:Name="PART_Editor" BorderThickness="0" Style="{x:Null}" Height="20" HorizontalAlignment="Stretch" Click="PART_Editor_Click">
                                    <TextBlock Text="{Binding Value, Converter={StaticResource StringFormatConverter}, ConverterParameter='{}{0:c}'}" TextWrapping="Wrap" />
                                </Button>
                            </ControlTemplate>
                        </dxg:GridColumn.EditTemplate>
                    </dxg:GridColumn>
                    <dxg:GridColumn x:Name="column_interval" FieldName="AccountingInterval" Header="Abrechnungsintervall" Width="130" />
				</dxg:GridControl.Columns>
				<dxg:GridControl.View>
					<dxg:TableView AutoWidth="true" ShowGroupPanel="False" ShowGroupedColumns="false" ShowTotalSummary="False" NavigationStyle="Cell" />
				</dxg:GridControl.View>
			</dxg:GridControl>
            <Popup x:Name="popup_costrateperiods" StaysOpen="false" Placement="MousePoint">
                <Border>
                    <Grid Background="White">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <WrapPanel>
                            <localView:CostRatePeriodControl CostRateType="{x:Static Shared:CostRatePeriodType.AmountOfMoney}"
                                    VM="{Binding EditVM.CostRatePeriods}" Foreground="#FF000000"
                                    ValueLabelText="Betrag (€)"
                                    ButtonTooltipText="Neuen Betrag hinzufügen" />
                        </WrapPanel>
                        <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>
</localView:BeWoView>