+ Reply to Thread
Results 1 to 4 of 4

Thread: enable/disable fonctions on map

  1. #1
    Yassine EL JADIDI
    Join Date
    Mar 2012
    Posts
    69
    Points
    0
    Answers Provided
    0


    0

    Default enable/disable fonctions on map

    Hello,
    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

  2. #2
    J McNeil
    Join Date
    Apr 2010
    Posts
    180
    Points
    53
    Answers Provided
    10


    0

    Default Re: enable/disable fonctions on map

    Yassine,

    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

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

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

    Code:
     <userControls:CollapsiblePanel x:Name="VideoWindow"  IsExpanded="False" 
                                               RenderTransformOrigin="0.5,0.5"
                                               VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Margin="15" Effect="{StaticResource dropShadow}" >
    
    </userControls:CollasiblePanel>

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

    Code:
    <Grid x:Name="AreaLine" HorizontalAlignment="Right"  VerticalAlignment="Center" Margin="0,15,15,0" Visibility="Collapsed">
    </Grid>
    In code behind (if you are handling a button click event you would state:

    Code:
      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;
                }
    
                else
                {
                   //Make it active and available
                    MyTextGrid.Visibility = Visibility.Visible;
    
                 //now do something
    
                  
    
                } 
                    };

    Jay
    Hopefully this helps...if so please mark my answer as answered.

  3. #3
    Yassine EL JADIDI
    Join Date
    Mar 2012
    Posts
    69
    Points
    0
    Answers Provided
    0


    0

    Default 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 :
    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" />
                    </Canvas>
    i want you to advise me ....

  4. #4
    Jennifer Nery

    Join Date
    May 2010
    Posts
    2,449
    Points
    289
    Answers Provided
    51


    0

    Default 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;
    Jennifer Nery
    Software Developer
    ArcGIS API for SL/WPF/WP7

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts