3 Replies Latest reply on May 1, 2012 9:46 AM by JNery-esristaff

    enable/disable fonctions on map

      i have some fonctions in my application like : identify, query...
      i want for each fonction..a button in my toolbar that enable or disable this funcion.
      for example, for my query, i have a textbox and a datagrid. i want that when the application run...this textbox and datagrid would be disable..and when i click in button"query"...it would be enabled.
      any idea about that please ?
      Thank you
        • Re: enable/disable fonctions on map

          For the textbox I think you would just set the Visibility property.  Visibility="Collapsed" or Visibility="Visible"

          I prefer to wrap my crontrols (textboxs, datagrids, etc) in larger control containers (DraggableWindow, Grid, orCollapsiblePanel) and then set them.

          If I use a DraggableWindow it would look like this...the "IsOpen" property changes when the corresponding button is click...it is either set to IsOpen = "true" or IsOpen = "false".  This makes it active or not

           <userControls:DraggableWindow x:Name="APNMapPanel" IsOpen="False" HorizontalAlignment="Right" VerticalAlignment="Top"
                     Margin="0,85,10,0" Effect="{StaticResource dropShadow}" Background="Black" Title="APN SEARCH">

          If you wrap your control with a CollapsiblePanel you would need to set the property IsExpanded="true" or False

           <userControls:CollapsiblePanel x:Name="VideoWindow"  IsExpanded="False" 
                                                     VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Margin="15" Effect="{StaticResource dropShadow}" >

          If I wrap my control in a grid I would set the Visibility property; Visibility="Collapsed" or Visibility="Visible"

          <Grid x:Name="AreaLine" HorizontalAlignment="Right"  VerticalAlignment="Center" Margin="0,15,15,0" Visibility="Collapsed">

          In code behind (if you are handling a button click event you would state:

            private void MyButton_Click(object sender, RoutedEventArgs e)
                      if (MyTextGrid.Visibility == Visibility.Visible)
                         //If Grid is Active/Visible than deactive it or make it not visible
                          MyTextGrid.Visibility = Visibility.Collapsed;
                         //Make it active and available
                          MyTextGrid.Visibility = Visibility.Visible;
                       //now do something

          Hopefully this helps...if so please mark my answer as answered.
          • Re: enable/disable fonctions on map
            Thank you McNeil for your answer,
            I want to enable or disable textbox in a canvas
            this is the code :
              <Canvas HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,70,21,0" Width="250" Grid.Column="2" Visibility="Collapsed">
                                <Rectangle Fill="#CC5C90B2" Stroke="Gray" RadiusX="10" RadiusY="10" Width="230" Height="55" />
                                <TextBlock Text="Type a query and click Execute" Foreground="White" FontSize="10" Margin="10,5,0,0" />
                                <TextBox x:Name="QueryTextBox" Width="150" Margin="15,22,0,0" Text="Site = 'Koutoubia'" />
                                <Button x:Name="QueryButton" Content="Execute" Margin="168,23,0,0" Click="QueryButton_Click" />

            i want you to advise me ....
            • Re: enable/disable fonctions on map
              Jay suggested you collapse the panel so you would not worry about TextBoxes/Buttons being used.

              You can also use IsHitTestVisible property of the Canvas, this will be inherited by its children and your TextBox and Button will not receive mouse events. But if you want a visual effect that the control is disabled. You can do QueryTextBox.IsEnabled = false; QueryButton.IsEnabled = false;