<localView:BeWoView x:Class="BeWo.View.Detail.PersonView" 
                    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
                    xmlns:uc="clr-namespace:BeWo.Controls;assembly=BeWo.Controls" 
                    xmlns:localView="clr-namespace:BeWo.View" 
                    xmlns:localSearchView="clr-namespace:BeWo.View.Search" 
                    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" 
                    Height="Auto" Width="Auto" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Focusable="True">
	<Grid x:Name="rootGrid">
		<Grid.Resources>
			<dxg:GridControl x:Key="grid_Relations" DataSource="{Binding Path=OrganisationRelations.VMList}">
				<dxg:GridControl.Columns>
					<dxg:GridColumn FieldName="Notice" Header="" FixedWidth="True" Width="24" ReadOnly="True">
						<dxg:GridColumn.CellTemplate>
							<DataTemplate>
								<Button Content="r" FontFamily="Webdings" Click="button_removeOrganisationRelation_Click" Width="18" Height="18" VerticalAlignment="Center" />
							</DataTemplate>
						</dxg:GridColumn.CellTemplate>
					</dxg:GridColumn>
					<dxg:GridColumn FieldName="OrganisationString" Header="Organisation" ReadOnly="True"/>
					<dxg:GridColumn FieldName="Mail" Header="geschäftl. Mail" />
					<dxg:GridColumn FieldName="Phone" Header="geschäftl. Tel." />
					<dxg:GridColumn FieldName="Fax" Header="geschäftl. Fax." />
					<dxg:GridColumn FieldName="Notice" Header="Notiz" />
				</dxg:GridControl.Columns>
				<dxg:GridControl.View>
					<dxg:TableView AutoWidth="true" ShowGroupPanel="False" ShowGroupedColumns="false" ShowTotalSummary="False" NavigationStyle="Cell" RowDoubleClick="TableView_OnRowDoubleClick" />
				</dxg:GridControl.View>
			</dxg:GridControl>
		</Grid.Resources>
		<uc:ShadowChrome>
			<GroupBox Style="{StaticResource MainContentGroupBoxStyle}">
				<GroupBox.Header>
					<StackPanel Orientation="Horizontal" VerticalAlignment="Bottom">
						<Image Source="..\..\Ressources\Icons\AnonymousUserDisabled.png" RenderTransformOrigin="0.5,0.5" Stretch="Uniform" Width="32">
							<Image.RenderTransform>
								<TransformGroup>
									<ScaleTransform ScaleX="1" ScaleY="1" />
									<SkewTransform AngleX="0" AngleY="0" />
									<RotateTransform Angle="0" />
									<TranslateTransform X="0" Y="5" />
								</TransformGroup>
							</Image.RenderTransform>
						</Image>
						<TextBox x:Name="firstnameTextBox" Text="{Binding FirstName}" Margin="10,0,0,0" Background="{x:Null}" Foreground="#FFFFFFFF" FontSize="22" BorderBrush="{x:Null}" VerticalAlignment="Bottom" Padding="0,0,0,0" />
						<TextBox Text="{Binding LastName}" Margin="3,0,0,0" Background="{x:Null}" Foreground="#FFFFFFFF" FontSize="22" BorderBrush="{x:Null}" VerticalAlignment="Bottom" Padding="0,0,0,0" />
					</StackPanel>
				</GroupBox.Header>
				<Grid Margin="0,3,0,0" Background="{StaticResource ObjectEditBackgroundBrush}">
					<Grid.RowDefinitions>
						<RowDefinition Height="Auto" />
						<RowDefinition Height="*" />
						<RowDefinition Height="Auto" />
					</Grid.RowDefinitions>
					<Rectangle Fill="{StaticResource PersonContentBrush}" Height="6" />
					<TabControl x:Name="root" Grid.Row="1" Style="{StaticResource ObjectEditTabControl}" BorderThickness="0,0,0,0" Padding="4,4,4,4">
						<TabItem Header="Details" IsSelected="True">
							<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
							<Grid x:Name="grid_details"> 
								<Grid.ColumnDefinitions>
									<ColumnDefinition Width="*" />
									<ColumnDefinition Width="20" />
									<ColumnDefinition Width="*" />
								</Grid.ColumnDefinitions>
								<Grid.RowDefinitions>
									<RowDefinition Height="Auto" />
									<RowDefinition Height="Auto" />
									<RowDefinition Height="Auto" />
									<RowDefinition Height="*" />
								</Grid.RowDefinitions>

								<GroupBox Header="Eigenschaften" Grid.RowSpan="3" Style="{DynamicResource ObjectEditGroupBox}">
									<Grid>
										<Grid.ColumnDefinitions>
											<ColumnDefinition Width="Auto" />
											<ColumnDefinition Width="*" />
										</Grid.ColumnDefinitions>
										<Grid.RowDefinitions>
											<RowDefinition Height="Auto" />
											<RowDefinition Height="Auto" />
											<RowDefinition Height="Auto" />
											<RowDefinition Height="Auto" />
											<RowDefinition Height="Auto" />
											<RowDefinition Height="Auto" />
											<RowDefinition Height="Auto" />
											<RowDefinition Height="*" />
										</Grid.RowDefinitions>

										<Label Grid.Column="0" Grid.Row="0" Content="Titel" />
										<Label Grid.Column="0" Grid.Row="1" Content="Vorname" />
										<Label Grid.Column="0" Grid.Row="2" Content="Nachname" />
										<Label Grid.Column="0" Grid.Row="3" Content="Geburtstag" />
										<Label Grid.Column="0" Grid.Row="4" Content="Geschlecht" />
										<Label Grid.Column="0" Grid.Row="5" Content="Funktion" />
										<Label x:Name="lblArchiviert" Grid.Column="0" Grid.Row="6" Content="Archiviert" />
										<Label Grid.Column="0" Grid.Row="7" VerticalAlignment="Top" Content="Notizen" />

										<ComboBox x:Name="comboBox_Title" Grid.Column="1" Grid.Row="0" Margin="3" Height="23" SelectedValue="{Binding Path=Title, Mode=TwoWay}" />
										<TextBox Grid.Column="1" Grid.Row="1" Margin="3" Height="23" Text="{Binding Path=FirstName, UpdateSourceTrigger=PropertyChanged}" />
										<TextBox Grid.Column="1" Grid.Row="2" Margin="3" Height="23" Text="{val:ValidationBinding Path=LastName, UpdateSourceTrigger=PropertyChanged}" />

										<!--<uc:MaskedTextBox Grid.Column="1" Grid.Row="3" Mask="00/00/0000" Margin="3" Height="23" Text="{Binding Path=DateOfBirth, Converter={StaticResource DateConverter}, UpdateSourceTrigger=PropertyChanged}" Width="Auto" HorizontalAlignment="Left" />-->
                                        <dxe:DateEdit MaskType="DateTimeAdvancingCaret" AllowNullInput="True" Grid.Column="1" Grid.Row="3" Height="23" Margin="3" EditValue="{Binding Path=DateOfBirth, UpdateSourceTrigger=PropertyChanged}"  Width="100" HorizontalAlignment="Left" />
										<Grid Grid.Column="1" Grid.Row="4" Width="Auto" HorizontalAlignment="Left" Margin="3,2,3,4" Height="23">
											<Grid.ColumnDefinitions>
												<ColumnDefinition Width="Auto" />
												<ColumnDefinition Width="*" />
											</Grid.ColumnDefinitions>
											<RadioButton Grid.Column="0" Margin="3" VerticalAlignment="Center" HorizontalAlignment="Left" IsChecked="{Binding Path=IsMale, UpdateSourceTrigger=PropertyChanged}" Content="männlich" />
											<RadioButton Grid.Column="1" Margin="3" VerticalAlignment="Center" HorizontalAlignment="Left" IsChecked="{Binding Path=IsFemale, UpdateSourceTrigger=PropertyChanged}" Content="weiblich" />
										</Grid>
										<ComboBox x:Name="comboBox_Function" Grid.Column="1" Grid.Row="5" Margin="3" Height="23" SelectedValue="{Binding Path=Function, Mode=TwoWay}" />
										<CheckBox x:Name="chkArchiviert" Grid.Column="1" Grid.Row="6" Margin="3,6,3,0" Height="23" IsChecked="{Binding Path=IsArchived, UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Stretch" />
										<TextBox Grid.Row="7" Grid.RowSpan="3" Grid.Column="1" Margin="3" VerticalAlignment="Stretch" VerticalScrollBarVisibility="Auto" AcceptsReturn="True" Text="{Binding Path=Notice, UpdateSourceTrigger=PropertyChanged}" HorizontalScrollBarVisibility="Hidden" TextWrapping="Wrap" AutoWordSelection="True" />
									</Grid>
								</GroupBox>

								<GroupBox Grid.Column="2" Grid.Row="0" Header="Adresse" Style="{DynamicResource ObjectEditGroupBox}">
									<Grid>
										<Grid.RowDefinitions>
											<RowDefinition Height="Auto" />
											<RowDefinition Height="Auto" />
											<RowDefinition Height="Auto" />
											<RowDefinition Height="Auto" />
										</Grid.RowDefinitions>
										<Grid.ColumnDefinitions>
											<ColumnDefinition Width="Auto" />
											<ColumnDefinition Width="*" />
										</Grid.ColumnDefinitions>

										<Label Grid.Column="0" Grid.Row="0" Margin="3" VerticalAlignment="Center" Content="Adresszusatz" />
										<Label Grid.Column="0" Grid.Row="1" Margin="3" VerticalAlignment="Center" Content="Strasse" />
										<Label Grid.Column="0" Grid.Row="2" Margin="3" VerticalAlignment="Center" Content="Postleitzahl" />
										<Label Grid.Column="0" Grid.Row="3" Margin="3" VerticalAlignment="Center" Content="Ort" />

										<TextBox Grid.Column="1" Grid.Row="0" Margin="3" Height="23" Text="{Binding Path=AddressLine1, UpdateSourceTrigger=PropertyChanged}" />
										<TextBox Grid.Column="1" Grid.Row="1" Margin="3" Height="23" Text="{Binding Path=Street, UpdateSourceTrigger=PropertyChanged}" />
										<TextBox Grid.Column="1" Grid.Row="2" Margin="3" Height="23" Text="{Binding Path=PostalCode, UpdateSourceTrigger=PropertyChanged}" />
										<TextBox Grid.Column="1" Grid.Row="3" Margin="3" Height="23" Text="{Binding Path=Town, UpdateSourceTrigger=PropertyChanged}" />

									</Grid>
								</GroupBox>

								<GroupBox Grid.Column="2" Grid.Row="1" Header="Rechnungsadresse" Style="{DynamicResource ObjectEditGroupBox}">
									<Grid>
										<Grid.RowDefinitions>
											<RowDefinition Height="Auto" />
											<RowDefinition Height="Auto" />
											<RowDefinition Height="Auto" />
										</Grid.RowDefinitions>
										<Grid.ColumnDefinitions>
											<ColumnDefinition Width="80" />
											<ColumnDefinition Width="*" />
										</Grid.ColumnDefinitions>

										<Label Grid.Column="0" Grid.Row="0" Margin="3" VerticalAlignment="Center" Content="Strasse" />
										<Label Grid.Column="0" Grid.Row="1" Margin="3" VerticalAlignment="Center" Content="Postleitzahl" />
										<Label Grid.Column="0" Grid.Row="2" Margin="3" VerticalAlignment="Center" Content="Ort" />

										<TextBox Grid.Column="1" Grid.Row="0" Margin="3" Height="23" Text="{Binding Path=InvoiceAddressStreet, UpdateSourceTrigger=PropertyChanged}" />
										<TextBox Grid.Column="1" Grid.Row="1" Margin="3" Height="23" Text="{Binding Path=InvoiceAddressPostalCode, UpdateSourceTrigger=PropertyChanged}" />
										<TextBox Grid.Column="1" Grid.Row="2" Margin="3" Height="23" Text="{Binding Path=InvoiceAddressTown, UpdateSourceTrigger=PropertyChanged}" />

									</Grid>
								</GroupBox>

								<GroupBox Grid.Column="2" Grid.Row="2" Header="Kontakt" Style="{DynamicResource ObjectEditGroupBox}" Margin="0,20,0,0">
									<Grid>
										<Grid.RowDefinitions>
											<RowDefinition Height="Auto" />
											<RowDefinition Height="Auto" />
											<RowDefinition Height="Auto" />
											<RowDefinition Height="Auto" />
                      <RowDefinition Height="Auto" />
										</Grid.RowDefinitions>
										<Grid.ColumnDefinitions>
											<ColumnDefinition Width="80" />
                                            <ColumnDefinition Width="Auto" />
											<ColumnDefinition Width="*" />
										</Grid.ColumnDefinitions>

										<Label Grid.Column="0" Grid.Row="0" Margin="3" VerticalAlignment="Center" Content="Handy" />
										<Label Grid.Column="0" Grid.Row="1" Margin="3" VerticalAlignment="Center" Content="Telefon" />
										<Label Grid.Column="0" Grid.Row="2" Margin="3" VerticalAlignment="Center" Content="Fax" />
										<Label Grid.Column="0" Grid.Row="3" Margin="3" VerticalAlignment="Center" Content="Mail" />
                    <Label Grid.Column="0" Grid.Row="4" Margin="3" VerticalAlignment="Center" Content="Homepage" />

                                        <TextBox Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="0" Margin="3" Height="23" Text="{Binding Path=PrivateMobilePhone, UpdateSourceTrigger=PropertyChanged}" />
                                        <TextBox Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="1" Margin="3" Height="23" Text="{Binding Path=PrivatePhone, UpdateSourceTrigger=PropertyChanged}" />
										<TextBox Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="2" Margin="3" Height="23" Text="{Binding Path=PrivateFax, UpdateSourceTrigger=PropertyChanged}" />

                                        <Button Grid.Column="1" Grid.Row="3" Margin="3" Height="21" Content="*" FontFamily="Wingdings" Click="EMailButton_OnClick" IsEnabled="{Binding Path=PrivateEMail, Converter={StaticResource ObjectBoolConverter}}"/>
										<TextBox Grid.Column="2" Grid.Row="3" Margin="3" Height="23" Text="{Binding Path=PrivateEMail, UpdateSourceTrigger=PropertyChanged}" />

                    <TextBox Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="4" Margin="3" Height="23" Text="{Binding Path=PrivateHomepage, UpdateSourceTrigger=PropertyChanged}" />

									</Grid>
								</GroupBox>
							</Grid>
							</ScrollViewer>
						</TabItem>
						<TabItem Header="Weitere Eigenschaften" IsSelected="True" Name="tabitem_varFields">
							<ScrollViewer VerticalScrollBarVisibility="Auto">
								<localView:VarFieldView VarFieldList="{Binding VarFields}" />
							</ScrollViewer>
						</TabItem>
						<TabItem Header="Organisationen" Selector.Selected="TabItemOrganisations_Selected">
							<Grid>
								
								<Grid.RowDefinitions>
									<RowDefinition Height="Auto" />
									<RowDefinition Height="*" />
								</Grid.RowDefinitions>

								<GroupBox x:Name="groupbox_newOrganisation" Header="Neue Zuordnung hinzufügen" Style="{DynamicResource ObjectEditGroupBox}">
									<Grid>
										<Grid.ColumnDefinitions>
											<ColumnDefinition Width="Auto" />
											<ColumnDefinition Width="*" />
											<ColumnDefinition Width="Auto" />
											<ColumnDefinition Width="*" />
										</Grid.ColumnDefinitions>
										<Grid.RowDefinitions>
											<RowDefinition Height="Auto" />
											<RowDefinition Height="Auto" />
											<RowDefinition Height="Auto" />
											<RowDefinition Height="Auto" />
											<RowDefinition Height="Auto" />
										</Grid.RowDefinitions>

										<Label Grid.Column="0" Grid.Row="0">Organisation</Label>
										<Label Grid.Column="0" Grid.Row="1">
											geschäftl. Mailadresse
										</Label>
										<Label Grid.Column="0" Grid.Row="2">
											geschäftl. Telefonnummer
										</Label>
										<Label Grid.Column="2" Grid.Row="0">geschäftl. Faxnummer</Label>
										<Label Grid.Column="2" Grid.Row="1">Notiz</Label>

										<uc:PopUpEdit NewButtonVisibility="Visible" 
                                                      NewClick="popupedit_organisation_NewClick" 
                                                      IsReadOnly="True" Grid.Column="1" Grid.Row="0" 
                                                      DeleteButtonVisibility="Collapsed" Height="23" 
                                                      Margin="3" Name="popupedit_organisation" 
                                                      PopUpClick="popupedit_organisation_PopUpClick" 
                                                      Text="{val:ValidationBinding Path=OrganisationRelations.NewVM.OrganisationString, UpdateSourceTrigger=PropertyChanged}" 
                                                      Cursor="Arrow"
                                                      PreviewMouseDoubleClick="Popupedit_organisation_OnPreviewMouseDoubleClick"/>
										<TextBox Grid.Column="1" Grid.Row="1" Height="23" Margin="3" Name="textbox_mail" Text="{Binding Path=OrganisationRelations.NewVM.Mail, UpdateSourceTrigger=PropertyChanged}" />
										<TextBox Grid.Column="3" Grid.Row="0" Height="23" Margin="3" Name="textbox_fax" Text="{Binding Path=OrganisationRelations.NewVM.Fax, UpdateSourceTrigger=PropertyChanged}" />
										<TextBox Grid.Column="1" Grid.Row="2" Height="23" Margin="3" Name="textbox_phone" Text="{Binding Path=OrganisationRelations.NewVM.Phone, UpdateSourceTrigger=PropertyChanged}" />
										<TextBox Grid.Column="3" Grid.Row="1" VerticalScrollBarVisibility="Auto" AcceptsReturn="True" Grid.RowSpan="2" Margin="3" Name="textbox_notice" Text="{Binding Path=OrganisationRelations.NewVM.Notice, UpdateSourceTrigger=PropertyChanged}" />

										<Button Height="25" Grid.ColumnSpan="4" Margin="3" Grid.Row="3" Name="button_addOrganisationRelation" Click="button_addOrganisationRelation_Click" HorizontalAlignment="Right">Zuordnung hinzufügen</Button>
									</Grid>
								</GroupBox>

								<GroupBox x:Name="GroupBoxOrganisation" Grid.Column="0" Margin="0 20 0 0" Grid.Row="1" Header="zugeordnete Organisationen" Style="{DynamicResource ObjectEditGroupBox}">


								</GroupBox>


								<Popup Grid.Row="6" Margin="10" Name="popup_organisation" StaysOpen="False" Placement="MousePoint" Width="370" Height="250" Closed="popup_Closed" Opened="popup_Opened">
									<localSearchView:OrganisationSearchView ItemSelected="OrganisationSearchView_OrganisationSelected" x:Name="organisationSearchView" />
								</Popup>

							</Grid>

						</TabItem>
						<TabItem Header="Dokumente" Name="tabitem_documents" Selector.Selected="tabitem_documents_Selected" />

					</TabControl>
					<Border Grid.Row="2" Grid.ColumnSpan="3" Height="40" Margin="0,10,0,0" VerticalAlignment="Stretch" Background="#FF000000">
						<Border.OpacityMask>
							<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
								<GradientStop Color="#19000000" Offset="0" />
								<GradientStop Color="#33FFFFFF" Offset="1" />
							</LinearGradientBrush>
						</Border.OpacityMask>

					</Border>
					<StackPanel Grid.ColumnSpan="3" Grid.Row="2" Orientation="Horizontal" VerticalAlignment="Center" Height="Auto" Margin="5,10,0,0" HorizontalAlignment="Right">
						<Button x:Name="btnSave" Content="Speichern" Margin="0,0,2,0" Command="ApplicationCommands.Save" Height="25" />
						<Button x:Name="btnClose" Content="Schließen" Margin="0,0,3,0" Command="ApplicationCommands.Close" Height="25" />
					</StackPanel>
				</Grid>
			</GroupBox>
		</uc:ShadowChrome>
	</Grid>
</localView:BeWoView>