AdamP

Badges

Third AnniversaryXamarin MVPSecond Anniversary250 Answers250 Likes1000 Comments100 Answers100 Likes500 Comments50 AnswersPhotogenic25 AnswersFirst Anniversary25 Likes100 Comments5 AnswersFirst Answer5 Likes10 CommentsName DropperFirst Comment

About

Username
AdamP
Location
AU
Joined
Visits
2,740
Last Active
Roles
University
Points
1,799
Twitter
@adpedley
LinkedIn URL
https://au.linkedin.com/in/adampedley
Github URL
https://github.com/adamped
Website
http://www.xamarinhelp.com
Badges
21

AdamP ✭✭✭✭✭

About

Username
AdamP
Location
AU
Joined
Visits
2,740
Last Active
Roles
University
Points
1,799
Twitter
@adpedley
LinkedIn URL
https://au.linkedin.com/in/adampedley
Github URL
https://github.com/adamped
Website
http://www.xamarinhelp.com
Badges
21
  • Re: The "XamlCTask" task failed unexpectedly.

    @pallavbohara that normally means that you have added something twice. Either with the same name, or maybe something to the root of a control that only supports a single entity.

    E.g.
    <ContentView>
    <Label />
    <Label />
    </ContentView>

  • Re: WHY I'M GETTING THIS ERROR WITH ASYNC METHOD???

    @SIUS

    public MainViewModel ()
    {
        this.FabCommand = new Command (this.FabAction);
        this._navigationService = DependencyService.Get<Services.INavigationService> ();
        this._messageService = DependencyService.Get<Services.IMessageService> ();
        Task.Run(async ()=>await UpdateTrips ()); // You have this option, or move it to an async function.
    }
    
    ic_save.Clicked += async (object sender, EventArgs e) => { await dvm.Save (); }; // Put async at the front as shown
    
  • Re: How to implement pull to refresh in listview in xamarin forms?

    My addition: https://xamarinhelp.com/pull-to-refresh-listview/

    Basically you just need to enabled these 3 properties, IsPullToRefreshEnabled, RefreshCommand and IsRefreshing if you want to bind it to a boolean property.

    <ListView ItemsSource="{Binding MyList}"
           IsPullToRefreshEnabled="True"
           RefreshCommand="{Binding RefreshCommand}"
           IsRefreshing="{Binding IsRefreshing}"/>
    
  • Re: Found a way to make ToolBarItems Visible/Invisible..without a custom renderer

    @AnthonyHarrison.3194 - The MVVM XAML way to make ToolbarItems Visible/Not Visible (technically its removing and adding them, as you can't actually make them invisible).

    #1. Create a new Control that inherits from ToolbarItem

          public class BindableToolbarItem: ToolbarItem
          {
    
            public BindableToolbarItem()
            {
                InitVisibility();
            }
    
            private async void InitVisibility()
            {
                OnIsVisibleChanged(this, false, IsVisible);
            }
    
            public new ContentPage Parent { set; get; }
    
            public bool IsVisible
            {
                get { return (bool)GetValue(IsVisibleProperty); }
                set { SetValue(IsVisibleProperty, value); }
            }
    
            public static BindableProperty IsVisibleProperty =
                BindableProperty.Create<BindableToolbarItem, bool>(o => o.IsVisible, false, propertyChanged: OnIsVisibleChanged);
    
            private static void OnIsVisibleChanged(BindableObject bindable, bool oldvalue, bool newvalue)
            {
                var item = bindable as BindableToolbarItem;
    
                if (item.Parent == null)
                    return;
    
                var items = item.Parent.ToolbarItems;
    
                if (newvalue && !items.Contains(item))
                {
                    items.Add(item);
                }
                else if (!newvalue && items.Contains(item))
                {
                    items.Remove(item);
                }
              }
          }
    

    #2. In your content pages attributes add this

    x:Name="this"

    and

    xmlns:control="clr-namespace:Mobile.Controls"

    #3. Add in your bindable toolbar items

    <ContentPage.ToolbarItems>
           <control:BindableToolbarItem Text="Delete" Icon="delete.png" Command="{Binding DeleteCommand}" Parent="{x:Reference this}" IsVisible="{Binding IsVisible}" />
      </ContentPage.ToolbarItems>
    
  • Re: OnBackButtonPressed

    @KenNickerson - The hacks for iOS, Android and UWP are all in the same blog post.

    OnBackButtonPressed is always called for hardware back button presses only. It doesn't get called for any software based back, hence iOS and the ActionBar on Android have issues. But the hardware back on Android and UWP called OnBackButtonPressed as expected.