Search This Blog

Wednesday, 26 September 2018

Set Custom Content on Xamarin Form (New Feature in 3.2.0) Navigation Toolbar

In Xamarin Forms 3.2.0  you can set the custom Navigation Icon & Navigation Text.




<ContentPage>
<NavigationPage.TitleView >
   <StackLayout HorizontalOptions="Start" Orientation="Horizontal">
<Image  HeightRequest="50" WidthRequest="50"  Source="Icon"></Image>
                <Label VerticalOptions="Center" Text="Pragnesh Mistry"  TextColor="White"    />
          </StackLayout>
</NavigationPage.TitleView>
</ContentPage>

Sunday, 16 September 2018

Xamarin Forms Timer

Xamarin Form Timer:

Xamarin Form Timer will execute the block of code in specified time interval.


 

// Here is the example that on the click of  Start Button The timer will execute the block of code for every second and update the Label Text & On the Click of Stop Button Timer will stop.

private void btnStartTimer_Clicked(object sender, EventArgs e)
{
    if (btnStartTimer.Text == "Start")
    {
        returnValue = true;
        btnStartTimer.Text = "Stop";
    }
    else
    {
        btnStartTimer.Text="Start";
        returnValue = false;
    }
    int count = 0;
    lblTimer.Text = "";
    Device.StartTimer(TimeSpan.FromSeconds(1), () =>
    {
        // Do something
        count += 1;
        Device.BeginInvokeOnMainThread(() =>
        {
            lblTimer.Text = count.ToString() ;
        });
            return returnValue; // True = Repeat again, False = Stop the timer
    });
}

Popular Posts