<UserControl x:Class="BeWo.View.Controls.ComboBoxTreeViewControlV2"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:dx="clr-namespace:DevExpress.Xpf.Core;assembly=DevExpress.Xpf.Core.v13.1"
             xmlns:shared="clr-namespace:BeWo.Core"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
  <Grid>
    <StackPanel x:Name="ComboBox_TreeView_Imitation" Orientation="Horizontal" Margin="3,0,3,3"
                Visibility="{Binding Path=PrototypeVM.IsGoalTreeVisible, Converter={StaticResource BoolVisibilityConverter}}">
      <TextBox x:Name="Imitationheader" Width="182" HorizontalAlignment="Left"
               Cursor="Arrow" VerticalContentAlignment="Center" Height="23" IsReadOnly="True"
               Visibility="{Binding Path=PrototypeVM.IsGoalTreeVisible, Converter={StaticResource BoolVisibilityConverter}}" />
      <Button Content="6" Click="OpenPopUpBtnClick" FontFamily="Webdings" FontSize="8" Height="19" Name="OpenPopUpBtn" Width="17" Margin="-22,0,0,0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" />
    </StackPanel>
    <Popup Grid.Row="1" x:Name="TreeViewPopup" AllowsTransparency="True"
           IsOpen="False" StaysOpen="False"
           Closed="PopUpClosedEvent" PopupAnimation="Slide">
      <Border BorderBrush="Black" BorderThickness="2" Background="#788991">
        <Grid>
          <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
          </Grid.RowDefinitions>
          <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
          </Grid.ColumnDefinitions>
          <Grid Grid.Row="0">
            <Grid.ColumnDefinitions>
              <ColumnDefinition Width="Auto" />
              <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <Label x:Name="SearchFieldLabel" Grid.Column="0" Content="Suche" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Left" />
            <TextBox x:Name="cbtv_search" Grid.Column="1" Margin="3" Height="23" Template="{StaticResource SearchTextBoxTemplate}" HorizontalAlignment="Stretch" />
          </Grid>
          <TreeView x:Name="Tree1" Margin="0" Grid.Row="1"
                    ItemTemplate="{DynamicResource servicecat_treeitemtemplate}"
                    ItemContainerStyle="{DynamicResource servicecat_treeitemstyle}"
                    BorderThickness="0" Background="White"
                    Loaded="Tree1_OnLoaded"
                    dx:ThemeManager.ThemeName="None">
            <TreeView.ItemsSource>
              <MultiBinding Converter="{StaticResource FilterDCConverter}">
                <MultiBinding.Bindings>
                  <Binding Path="TreeViewSourceList" />
                  <Binding ElementName="cbtv_search" Path="Text" />
                </MultiBinding.Bindings>
              </MultiBinding>
            </TreeView.ItemsSource>
            <TreeView.Resources>
              <Style x:Key="servicecat_treeitemstyle" TargetType="TreeViewItem">
                <Setter Property="IsExpanded" Value="{Binding Path=IsExpanded, Mode=TwoWay}" />
              </Style>
              <HierarchicalDataTemplate x:Key="servicecat_treeitemtemplate" DataType="{x:Type shared:ServiceCategoryTreeItem}" ItemsSource="{Binding Path=Children}">
                <Grid>
                  <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                  </Grid.ColumnDefinitions>
                  <CheckBox Tag="{Binding}" 
                            Click="Bd_OnClick" 
                            IsChecked="{Binding Path=IsChecked}" 
                            Margin="3 2" 
                            VerticalAlignment="Center" />
                  <TextBlock Tag="{Binding}" 
                             MouseDown="BdText_OnMouseDown" 
                             Grid.Column="1" Margin="3 2" 
                             Text="{Binding Path=Name}" 
                             VerticalAlignment="Center" />
                </Grid>
              </HierarchicalDataTemplate>
            </TreeView.Resources>
          </TreeView>
          <Grid Grid.Row="2">
            <Grid.ColumnDefinitions>
              <ColumnDefinition Width="*" />
              <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <CheckBox x:Name="DeSelectAllCheckBox" Click="DeSelectAllOnClick" Content="Alle Leistungskategorien" Margin="3" VerticalAlignment="Center" />
            <Button Grid.Column="1" x:Name="ApplyBtn" Margin="3" Height="23"
                    Content="Übernehmen" Click="ApplyBtnClose" HorizontalAlignment="Right" />
          </Grid>
        </Grid>
      </Border>
    </Popup>
  </Grid>
</UserControl>
