Disable/Enable applicationbar Button in runtime with event textchanged (Windows Phone)
        Posted  
        
            by 
                user3621634
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by user3621634
        
        
        
        Published on 2014-05-27T02:36:34Z
        Indexed on 
            2014/05/27
            15:26 UTC
        
        
        Read the original article
        Hit count: 249
        
In this part of the code is the event TextChanged to enable the button in te applicationbar
Code in C#
     private void Textbox_TextChanged(object sender, EventArgs e) {
        ApplicationBarIconButton btn_guardar = ApplicationBar.Buttons[0] as applicationBarIconButton;
        if (!string.IsNullOrEmpty(txt_nom_usuario.Text) && !string.IsNullOrEmpty(txt_edad_usuario.Text) && !string.IsNullOrEmpty(txt_peso_usuario.Text))
        {
            btn_guardar.IsEnabled = true;
        }
        else
            btn_guardar.IsEnabled = false; 
    }
Code XAML
<phone:PhoneApplicationPage.ApplicationBar>
    <shell:ApplicationBar Mode="Default" IsVisible="True">
        <shell:ApplicationBarIconButton x:Name="btn_guardar" IconUri="/icons/appbar.save.rest.png" Text="Guardar" Click="btn_guardar_Click" IsEnabled="False" />
        <shell:ApplicationBarIconButton x:Name="btn_atras" IconUri="/icons/appbar.back.rest.png" Text="Atrás" Click="btn_atras_Click" />
    </shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>
        <TextBlock x:Name="lbl_ingresanombre" Height="39" Margin="60,28,0,0" TextWrapping="Wrap" HorizontalAlignment="Left" VerticalAlignment="Top" Width="248" FontSize="29.333" FontFamily="{StaticResource Helvetica}"><Run Text="Ingresa "/><Run Text="tu nombre"/></TextBlock>
        <TextBox x:Name="txt_nom_usuario" Height="63" Margin="47,58,69,0" TextWrapping="Wrap" Text="
" FontSize="21.333" VerticalAlignment="Top" IsEnabled="True" />
        <TextBlock x:Name="lbl_edad" Height="38" Margin="60,117,0,0" TextWrapping="Wrap" Text="Ingresa tu edad" VerticalAlignment="Top" FontSize="29.333" HorizontalAlignment="Left" FontFamily="{StaticResource Helvetica}"/>
        <TextBox x:Name="txt_edad_usuario" InputScope="TelephoneLocalNumber" Height="63" TextWrapping="Wrap" Text="
" FontSize="21.333" Margin="47,147,69,0" VerticalAlignment="Top" MaxLength="3" />
© Stack Overflow or respective owner