<UserControl x:Class="InABox.Wpf.Dashboard.Editor.DynamicDashboardDataEditor"
             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:local="clr-namespace:InABox.Wpf.Dashboard.Editor"
             mc:Ignorable="d" 
             xmlns:dg="clr-namespace:InABox.DynamicGrid"
             xmlns:wpf="clr-namespace:InABox.WPF"
             d:DesignHeight="450" d:DesignWidth="800"
             x:Name="Control">
    <UserControl.Resources>
        <wpf:BooleanToVisibilityConverter x:Key="notBoolToVisibility" TrueValue="Collapsed" FalseValue="Visible"/>
        <wpf:BooleanToVisibilityConverter x:Key="boolToVisibility" TrueValue="Visible" FalseValue="Collapsed"/>
    </UserControl.Resources>
    <Grid DataContext="{Binding ElementName=Control}">
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <local:DynamicDashboardDataQueryGrid x:Name="QueryGrid" Grid.Row="0"
                                             OnChanged="QueryGrid_OnChanged"
                                             Visibility="{Binding HasMultipleQueries,Converter={StaticResource boolToVisibility}}"/>
        <dg:EmbeddedDynamicEditorForm x:Name="QueryEditor" Grid.Row="0"
                                      Visibility="{Binding HasMultipleQueries,Converter={StaticResource notBoolToVisibility}}"
                                      ButtonsVisible="False"
                                      TabsVisible="False"/>
        <DockPanel Visibility="{Binding HasMultipleQueries,Converter={StaticResource notBoolToVisibility}}"
                   Grid.Row="1"
                   Margin="0,5,0,0"
                   LastChildFill="False">
            <Button Content="Add New Data Source"
                    Padding="5" DockPanel.Dock="Right"
                    Click="Button_Click"/>
        </DockPanel>
    </Grid>
</UserControl>
