<UserControl x:Class="FDOT.GIS.Framework.Examples.Views.QueryByAddressView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:behavior="clr-namespace:FDOT.GIS.Client.Behaviors;assembly=FDOT.GIS.Client"
    xmlns:cal="clr-namespace:Caliburn.Micro;assembly=Caliburn.Micro"
    xmlns:controls="clr-namespace:FDOT.GIS.Client.Controls;assembly=FDOT.GIS.Client"
    xmlns:interactivity="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
    xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
    xmlns:toolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"
    mc:Ignorable="d">

  <toolkit:BusyIndicator IsBusy="{Binding IsBusy}" BusyContent="Executing Query...">
    <Grid x:Name="LayoutRoot" Background="Transparent">
      <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"/>
      </Grid.RowDefinitions>


      <sdk:Label Content="Layer: " VerticalAlignment="Center" Margin="5,0,0,0" Grid.Row="0" Grid.Column="0" />
      <controls:DropdownTreeView
        ItemsSource="{Binding FeatureTypes}"
        SelectedValue="{Binding SelectedFeatureType , Mode=TwoWay}"
        DisplayMemberPath="Name"
        DefaultGroupName="Additional Layers"
        GroupMemberPath="GroupName"
        GroupsToExpand="Recently Queried"
        SortByGroup="True"
        cal:Message.Attach="[Event Loaded] = [ItemsLoaded($source, $eventArgs)];"
        Grid.Row="0" Grid.Column="1" MinWidth="100" Margin="5"
            />

      <sdk:Label Grid.Row="1" Grid.Column="0" Content="Street" VerticalAlignment="Center" Margin="5" />
      <TextBox Grid.Row="1" Grid.Column="1"
               Text="{Binding Address.StreetAddress, Mode=TwoWay}"
               cal:Message.Attach="[Event TextChanged] = [ValidateAddressSearchCriteria];[Event Loaded] = [ValidateAddressSearchCriteria];"
               Margin="3">
        <interactivity:Interaction.Behaviors>
          <behavior:UpdateOnTextChangedBehavior/>
        </interactivity:Interaction.Behaviors>
      </TextBox>

      <sdk:Label Grid.Row="2" Grid.Column="0" Content="City" VerticalAlignment="Center" Margin="5" />
      <TextBox Grid.Row="2" Grid.Column="1" Text="{Binding Address.City, Mode=TwoWay}" Margin="3" />

      <sdk:Label Grid.Row="3" Grid.Column="0" Content="Zip Code" VerticalAlignment="Center" Margin="5" />
      <TextBox Grid.Row="3" Grid.Column="1" Text="{Binding Address.ZipCode, Mode=TwoWay}" Margin="3" />

      <sdk:Label Grid.Row="4" Grid.Column="0" Content="Buffer Distance" VerticalAlignment="Center" Margin="5" />
      <TextBox Grid.Row="4" Grid.Column="1" Text="{Binding BufferRadius, Mode=TwoWay}" Margin="3" />

      <sdk:Label Grid.Row="5" Grid.Column="0" Content="Buffer Units" VerticalAlignment="Center" Margin="5" />
      <ComboBox SelectedValue="{Binding BufferUnit, Mode=TwoWay}"
                ItemsSource="{Binding BufferUnits}" 
                cal:Message.Attach="[Event Loaded] = [SetDefaultUnit];"
                Grid.Row="5" Grid.Column="1" 
                MinWidth="85" Margin="5">
        <ComboBox.ItemTemplate>
          <DataTemplate>
            <sdk:Label Content="{Binding}"/>
          </DataTemplate>
        </ComboBox.ItemTemplate>
      </ComboBox>

      <Button Grid.Row="6" Grid.ColumnSpan="2" Content="Execute Query"
                Width="200" HorizontalAlignment="Center"
                IsEnabled="{Binding IsValidSearchAddress, Mode=TwoWay}"
                cal:Message.Attach="[Event Click] = [ExecuteQuery];"
                Margin="5" />
    </Grid>
  </toolkit:BusyIndicator>
</UserControl>
