<view:BeWoView x:Class="BeWo.View.Detail.TextbausteinView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:view="clr-namespace:BeWo.View"
             xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
             xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"
             xmlns:validation="clr-namespace:BeWo.Validation"
             xmlns:detail="clr-namespace:BeWo.View.Detail"
                Height="Auto" Width="Auto" HorizontalAlignment="Stretch" 
			 VerticalAlignment="Stretch" Focusable="True">
    <view:BeWoView.Resources>
        <detail:IsOnlyForEmployeeRightsConverter x:Key="IsOnlyForEmployeeRightsConverter" />
    </view:BeWoView.Resources>
    <GroupBox Name="root" Header="Aktuell definierte Textbausteine" Style="{StaticResource ObjectEditGroupBox}">
        <Grid  VerticalAlignment="Stretch">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="*" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <Label Grid.Column="0" Grid.Row="0">Name</Label>
                <TextBox Grid.Column="1" Grid.Row="0" Width="100" Text="{validation:ValidationBinding Path=NewVM.Name}"></TextBox>
                <Label Grid.Column="2" Grid.Row="0">Position</Label>
                <dxe:SpinEdit Grid.Column="3" Grid.Row="0" Width="100" Height="23" MinValue="0" IsFloatValue="False" Value="{Binding Path=NewVM.Position, Mode=TwoWay, Converter={StaticResource Int2DecimalConverter}, UpdateSourceTrigger=PropertyChanged}"></dxe:SpinEdit>
                <Label Grid.Column="4" Grid.Row="0">Kategorie</Label>
                <ComboBox Grid.Column="5" Grid.Row="0" Width="150" Height="23" ItemsSource="{Binding Path=PossibleCategories, Mode=OneWay}" SelectedItem="{Binding Path=NewVM.ServiceCategory}" />
                <Label Grid.Column="0" Grid.Row="1">Text</Label>
                <TextBox Grid.Column="1" Grid.Row="1" Grid.ColumnSpan="5" AcceptsReturn="True" MaxWidth="469" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" TextWrapping="Wrap" Height="100" Margin="0,3,0,0" Text="{Binding Path=NewVM.Text, UpdateSourceTrigger=PropertyChanged}"></TextBox>
                <Button Grid.Column="4" Grid.Row="2" x:Name="AddTextbausteinButton" Margin="3" HorizontalAlignment="Right" Grid.ColumnSpan="2" Click="ButtonAddTextbaustein_Click">Hinzufügen</Button>
            </Grid>
            <dxg:GridControl Grid.Column="0" Grid.Row="1" x:Name="datagrid_textbausteine" Margin="0,10,0,0" 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" IsEnabled="{Binding Path=DataContext.RowData.Row, Converter={StaticResource IsOnlyForEmployeeRightsConverter}, RelativeSource={RelativeSource TemplatedParent}}" FontFamily="Webdings" Width="18" Height="18" VerticalAlignment="Center" />
                            </DataTemplate>
                        </dxg:GridColumn.CellTemplate>
                    </dxg:GridColumn>
                    <dxg:GridColumn FieldName="Name" Header="Name">
                        <dxg:GridColumn.DisplayTemplate>
                            <ControlTemplate>
                                <dxe:TextEdit EditMode="InplaceInactive" Text="{Binding Path=DataContext.RowData.Row.Name, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
                                    IsEnabled="{Binding Path=DataContext.RowData.Row, Converter={StaticResource IsOnlyForEmployeeRightsConverter}, RelativeSource={RelativeSource TemplatedParent}}"></dxe:TextEdit>
                            </ControlTemplate>
                        </dxg:GridColumn.DisplayTemplate>
                        <dxg:GridColumn.EditTemplate>
                            <ControlTemplate>
                                <dxe:TextEdit x:Name="PART_Editor" EditMode="InplaceActive" Text="{Binding Path=DataContext.RowData.Row.Name, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
                                    IsEnabled="{Binding Path=DataContext.RowData.Row, Converter={StaticResource IsOnlyForEmployeeRightsConverter}, RelativeSource={RelativeSource TemplatedParent}}"></dxe:TextEdit>
                            </ControlTemplate>
                        </dxg:GridColumn.EditTemplate>
                    </dxg:GridColumn>
                    <dxg:GridColumn FieldName="Position" Header="Position">
                        <dxg:GridColumn.DisplayTemplate>
                            <ControlTemplate>
                                <dxe:SpinEdit EditMode="InplaceInactive" MinValue="0" IsFloatValue="False" 
                                              Value="{Binding Path=DataContext.RowData.Row.Position, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" 
                                              IsEnabled="{Binding Path=DataContext.RowData.Row, Converter={StaticResource IsOnlyForEmployeeRightsConverter}, RelativeSource={RelativeSource TemplatedParent}}"></dxe:SpinEdit>
                            </ControlTemplate>
                        </dxg:GridColumn.DisplayTemplate>
                        <dxg:GridColumn.EditTemplate>
                            <ControlTemplate>
                                <dxe:SpinEdit x:Name="PART_Editor" EditMode="InplaceActive" MinValue="0" IsFloatValue="False" 
                                              Value="{Binding Path=DataContext.RowData.Row.Position, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" 
                                              IsEnabled="{Binding Path=DataContext.RowData.Row, Converter={StaticResource IsOnlyForEmployeeRightsConverter}, RelativeSource={RelativeSource TemplatedParent}}"></dxe:SpinEdit>
                            </ControlTemplate>
                        </dxg:GridColumn.EditTemplate>
                    </dxg:GridColumn>
                    <dxg:GridColumn FieldName="Text" Header="Text">
                        <dxg:GridColumn.DisplayTemplate>
                            <ControlTemplate>
                                <dxe:TextEdit EditMode="InplaceInactive" Text="{Binding Path=DataContext.RowData.Row.Text, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
                                    ></dxe:TextEdit>
                            </ControlTemplate>
                        </dxg:GridColumn.DisplayTemplate>
                        <dxg:GridColumn.EditTemplate>
                            <ControlTemplate>
                                <dxe:TextEdit x:Name="PART_Editor" EditMode="InplaceActive" Text="{Binding Path=DataContext.RowData.Row.Text, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
                                    IsEnabled="{Binding Path=DataContext.RowData.Row, Converter={StaticResource IsOnlyForEmployeeRightsConverter}, RelativeSource={RelativeSource TemplatedParent}}"></dxe:TextEdit>
                            </ControlTemplate>
                        </dxg:GridColumn.EditTemplate>
                    </dxg:GridColumn>
                    <dxg:GridColumn Header="Nur für Ersteller sichtbar" x:Name="EigenerTextbausteinSpalte">
                        <dxg:GridColumn.CellTemplate>
                            <DataTemplate>
                                <dxe:CheckEdit HorizontalAlignment="Center" 
                                               IsChecked="{Binding Path=DataContext.RowData.Row.IsOnlyForEmployee, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" 
                                               IsEnabled="{Binding Path=DataContext.RowData.Row, ConverterParameter=IsOnlyForEmployeeCheckBox, Converter={StaticResource IsOnlyForEmployeeRightsConverter}, RelativeSource={RelativeSource TemplatedParent}}"/>
                            </DataTemplate>
                        </dxg:GridColumn.CellTemplate>
                    </dxg:GridColumn>
                    <dxg:GridColumn FieldName="ServiceCategory" Header="Kategorie">
                        <dxg:GridColumn.EditSettings>
                            <dxe:ComboBoxEditSettings ItemsSource="{Binding Path=PossibleCategories}"></dxe:ComboBoxEditSettings>
                        </dxg:GridColumn.EditSettings>
                    </dxg:GridColumn>
                </dxg:GridControl.Columns>
                <dxg:GridControl.View>
                    <dxg:TableView AutoWidth="true" ShowGroupPanel="False" ShowGroupedColumns="false" ShowTotalSummary="False" NavigationStyle="Cell" ShowingEditor="GridViewBase_OnShowingEditor" />
                </dxg:GridControl.View>
            </dxg:GridControl>
        </Grid>
    </GroupBox>
</view:BeWoView>
