<UserControl x:Class="BeWo.View.Controls.ComboBoxTreeViewControl"
             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="http://schemas.devexpress.com/winfx/2008/xaml/core"
             xmlns:clientPartials="clr-namespace:BS.Shared.DataContracts.ClientPartials;assembly=BS.Shared"
             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 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="treeitemtemplate"
                                          DataType="{x:Type clientPartials:SupportConceptGoalDC}"
                                          ItemsSource="{Binding Path=Children}">
                  <Grid HorizontalAlignment="Left">
                    <Grid.ColumnDefinitions>
                      <ColumnDefinition Width="Auto" />
                      <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>
                    <CheckBox x:Name="Bd" Tag="{Binding}"
                              IsChecked="{Binding Path=IsChecked}"
                              Visibility="{Binding Path=HasParent, Converter={StaticResource BoolVisibilityConverter}}"
                              Grid.Column="0" Margin="3 2"
                              VerticalAlignment="Center"
                              Click="Bd_OnClick" />
                    <TextBlock x:Name="BdText" Tag="{Binding}"
                               Grid.Column="1" Margin="3 2"
                               Text="{Binding Path=Name}"
                               VerticalAlignment="Center" HorizontalAlignment="Left" Foreground="Black" MouseDown="BdText_OnMouseDown" TextAlignment="Left"/>
                  </Grid>
                </HierarchicalDataTemplate>
              </TreeView.Resources>
            </TreeView>
            <Grid Grid.Row="2">
              <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="*" />
              </Grid.ColumnDefinitions>
              <CheckBox x:Name="DeSelectAllCheckBox" Click="DeSelectAllOnClick" IsChecked="False" Content="Alle Ziele" 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>
