Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all 91519 articles
Browse latest View live

Couple of problems with ListView context actions (UWP)

$
0
0

I'm having a problem with the list view context action (delete) on a UWP project. I have no idea of the same issues apply on iOS or Android.

1) If you add three items to a list, use the context action to delete one of them, then add another new item to the list, then you cannot delete the third item on the list any longer even tho the context menu appears. The context action command parameter references the previously deleted item even tho it no longer exists in the datasource. You can delete any of the other items, but then you get a similar unable to delete issue with any other new ones that you add.

2) If the list view's viewcell is a stack layout of horizontal labels, swiping on whitespace between labels does not display the context menu. Using a Grid behaves as expected.

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="Views.TestPage2">

  <StackLayout>
    <Button Text="Button"  Command="{Binding ButtonCommand}" />
    <Label Text="{Binding Counter}"/>

    <ListView x:Name="ItemsListView" ItemsSource="{Binding DataSource}"
                                     HorizontalOptions = "LayoutOptions.FillAndExpand"
                                     VerticalOptions = "LayoutOptions.FillAndExpand">
      <ListView.ItemTemplate>
        <DataTemplate>
          <ViewCell>
            <ViewCell.ContextActions>
              <MenuItem Clicked="OnDelete" CommandParameter="{Binding .}"  Text="Delete" IsDestructive="True" />
            </ViewCell.ContextActions>

            <StackLayout Orientation="Horizontal"  Padding="10,0,10,0">
              <Label   Text="{Binding Title}"  FontSize="Medium" HorizontalOptions="StartAndExpand"/>
              <Label  Text="{Binding Quantity}" FontSize="Medium" HorizontalOptions="EndAndExpand"/>
            </StackLayout>
          </ViewCell>
        </DataTemplate>
      </ListView.ItemTemplate>
    </ListView>
  </StackLayout>
</ContentPage>


using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Xamarin.Forms;

namespace Views
{
    public partial class TestPage2 : ContentPage
    {
        public TestPage2()
        {
            InitializeComponent();
            var model = new TestListViewModel();
            this.BindingContext = model;
        }

        public void OnDelete(object sender, EventArgs e)
        {
            var mi = ((MenuItem)sender);
            ((TestListViewModel)this.BindingContext).RemoveItem((TestListViewDataItem)mi.CommandParameter);
        }
    }

    public class TestListViewModel : INotifyPropertyChanged
    {
        public TestListViewModel()
        {
            DataSource = new ObservableCollection<Views.TestListViewDataItem>();

            ButtonCommand = new Command(() =>
            {
                Counter++;
                DataSource.Add(new Views.TestListViewDataItem(string.Format("item : {0}", Counter), 0));
            });
        }

        public void RemoveItem(TestListViewDataItem item)
        {
            DataSource.Remove(item);
        }

        public Command ButtonCommand { get; set; }

        public ObservableCollection<TestListViewDataItem> DataSource { get; set; }

        public TestListViewDataItem SelectedItem { get; set; }

        public int Counter { get; set; }

        public event PropertyChangedEventHandler PropertyChanged;

        protected void OnPropertyChanged(string PropertyName)
        {
            PropertyChangedEventHandler handler = PropertyChanged;

            if (handler != null)
                handler(this, new PropertyChangedEventArgs(PropertyName));
        }

    }

    public class TestListViewDataItem
    {
        public TestListViewDataItem(string title, int quantity)
        {
            Title = title;
            Quantity = quantity;
        }

        public string Title { get; set; }

        public int Quantity { get; set; }
    }
}

How to change the ListView Selection Color in Xamarin Forms ?

$
0
0

I have a ListView and I want to change the CellView color when I select the ListView? How to achieve this in Xamarin Forms ?

How to bind HTML String to WebView?

$
0
0

I've got a bindable string that's populated with HTML.

    public string Description
    {
        get { return _description; }
        set
        {
            _description = value;
            OnPropertyChanged();
        }
    }

Now I'd like that string to be bound to a webview

  <WebView Source="{Binding Description}" VerticalOptions ="FillAndExpand"/>

but this isn't working. Unfortunately the Docs for WebViewSource hasn't been entered yet.

How can I bind a string of HTML to a WebView?

Automatically select all text on focus in Entry,Editor,Label

$
0
0

How to automatically select all text on focus in entry ?

Checkbox with Xamarin

$
0
0

Hi @all,

I have a question regarding a Windows Phone 8.1 Silverlight Project. I would like to use a checkbox in the app. Actually I found an implementation for checkbox in Xlabs, but unfortunately it seems that I am obviously not able to use it properly. When I set in xaml Checked=true then the marker will be displayed well, when checking or unchecking it again. But in default mode or when setting it to false then checking or unchecking won't display the marker in my case. In the Custom Renderer the properties are set accordingly but nothing is displayed. Does anyone have an idea or did anyone mentioned something liek this before? Any hint or advice might be helpful.

Thanks
Jérôme

Binding ViewModel to custom UI not Binding Items to control

$
0
0

I have a home Page that contains a custom control 'MenuItemControl'. This control contains a formatted StackLayout with some labels, that I want to display the text that is being bound to it which works until I bind the MenuItemViewModel to it, then It does not bind to the custom control, and the text is not updating. It seems like the custom control contains the binding context, but the bindings don't seem to take effect. What is wrong with what I'm doing? This seems like it should be a piece of cake:

Home page :

<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:local="clr-namespace:TamarianApp;assembly=TamarianApp" xmlns:controls="clr-namespace:XLabs.Forms.Controls;assembly=XLabs.Forms"  xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="TamarianApp.Home">
<Grid>
    <StackLayout x:Name="main_view">
        <ScrollView>
            <StackLayout>


                <!-- new menu -->

                <local:MenuItemControl x:Name="lengthMenuItem" Title="{Binding Title}" SubTitle="{Binding SubTitle}" Test="{Binding teststring}"></local:MenuItemControl>
                <BoxView Margin="0, -7, 0, 0" HorizontalOptions="FillAndExpand" HeightRequest="1" BackgroundColor="#f1f1f1"></BoxView>
            </StackLayout>
        </ScrollView>
        <StackLayout BackgroundColor="#fafafa"  HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" >
            <BoxView HorizontalOptions="FillAndExpand"  HeightRequest="3" BackgroundColor="#f1f1f1"></BoxView>
        </StackLayout>
    </StackLayout>
    <ActivityIndicator x:Name="loading_activity" IsRunning="false" VerticalOptions="CenterAndExpand" HorizontalOptions="CenterAndExpand"></ActivityIndicator>
</Grid>

</ContentPage>

Home page C#:

public partial class Home : ContentPage
    {
        public MenuItemModelView modelview;
        public string teststring { get; set; } = "this is a test";
        public Home()
        {
            InitializeComponent();

            modelview = new MenuItemModelView
            {
                PageTo = new LengthPage(),
                Title = "Length",
                SubTitle = "10"
            };


            lengthMenuItem.BindingContext = modelview;


            NavigationPage.SetHasNavigationBar(this, true);
            Title = "Home";

        }
    }
}

Custom control (MenuItemControl):

    public class MenuItemControl : ContentView
    {
        StackLayout main;
        Label title, subTitle;
        public Command itemClicked;
        public static  BindableProperty ItemClickedCommandProperty = BindableProperty.Create("ItemClicked", typeof(MenuItemControl), typeof(Command),null, BindingMode.TwoWay);
        public static readonly BindableProperty TitleProperty = BindableProperty.Create("Title", typeof(MenuItemControl), typeof(string), null, defaultBindingMode:BindingMode.TwoWay);
        public static readonly BindableProperty SubTitleProperty = BindableProperty.Create("SubTitle", typeof(MenuItemControl), typeof(string), null, defaultBindingMode: BindingMode.TwoWay);
        public static BindableProperty TestProperty = BindableProperty.Create("Test", typeof(MenuItemControl), typeof(string),null, BindingMode.TwoWay);

        public string Test
        {
            get
            {
                return (string)GetValue(TestProperty);
            }
            set
            {
                SetValue(TestProperty, value);
            }
        }

        public string Title
        {
            get
            {
                return (string)GetValue(TitleProperty);
            }
            set
            {
                title.Text = value;
                SetValue(TitleProperty, value);
            }
        }

        public string SubTitle
        {
            get
            {
                return (string)GetValue(SubTitleProperty);
            }
            set
            {
                subTitle.Text = value;
                SetValue(SubTitleProperty, value);
            }
        }


        public Command ItemClickedCommand
        {
            get
            {
                return (Command)GetValue(ItemClickedCommandProperty);
            }
            set
            {
                itemClicked = value;
                SetValue(ItemClickedCommandProperty, value);
            }
        }

        public MenuItemControl()
        {
            TapGestureRecognizer itemTapped = new TapGestureRecognizer();
            itemTapped.Tapped += ItemWasClicked;

            BoxView line = new BoxView
            {
                HeightRequest = 1,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                BackgroundColor = Color.FromHex("#f1f1f1")
            };

            title = new Label
            {
                Text = this.Title,
                Margin = new Thickness(10, 2, 0, 0),
                HorizontalOptions = LayoutOptions.StartAndExpand,
            };

             subTitle = new Label
            {
                Text = this.SubTitle,
                Margin = new Thickness(10, 2, 10, 0),
                FontSize = 14,
                TextColor = Color.FromHex("#c1c1c1"),
                HorizontalOptions = LayoutOptions.End,
            };

            Image image = new Image
            {
                HorizontalOptions = LayoutOptions.End,
                Source = "icons/blue/next",
                WidthRequest = 20
            };
            main = new StackLayout()
            {

                Children = {

                    line,
                    new StackLayout{
                        Orientation = StackOrientation.Horizontal,
                        HorizontalOptions = LayoutOptions.Fill,
                        Padding = new Thickness(10),
                        Children ={

                            title,
                            subTitle,
                            image
                        }
                    }
                }
            };
            main.GestureRecognizers.Add(itemTapped);
            Content = main;
        }

        public void ItemWasClicked(object sender, EventArgs e)
        {
            itemClicked.CanExecute(true);
        }
    }

View model (MenuItemViewModel):

public class MenuItemModelView : ViewModel
    {
        private string title { get; set; }
        private string subtitle { get; set; }
        private Page pageto { get; set; }
        private Command MenuItemSelectedCommand { get; set; }

        public MenuItemModelView()
        {
            MenuItemSelectedCommand = new Command(async() => await OnMenuItemSelectedCommand());
        }

        public string Title
        {
            get
            {
                return title;
            }
            set
            {
                if (value != title)
                {
                    title = value;
                    OnPropertyChanged();
                }
            }
        }

        public string SubTitle
        {
            get
            {
                return subtitle;
            }
            set
            {
                if (value != subtitle)
                {
                    subtitle = value;
                    OnPropertyChanged();
                }
            }
        }

        public Page PageTo
        {
            get
            {
                return pageto;
            }
            set
            {
                if (value != pageto)
                {
                    pageto = value;
                    OnPropertyChanged();
                }
            }
        }

        public async Task<bool> OnMenuItemSelectedCommand()
        {
            if (PageTo != null)
            {
                await CurrentPage.Navigation.PushAsync(PageTo);
                return true;
            }
            return false;
        }
    }

Back button from causes crash on Android when page is MasterDetail

$
0
0

I'm seeing a crash on Android when the user presses the back button on their device while on the root MainPage of the application which happens to be a MasterDetail page. It looks to be the disposing of the Detail page that is the issue.

I'm using Xamarin.Forms 2.3.3-pre3 and building using Android 7.0 SDK.

Here is the stack trace:

  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/3819/96c7ba6c/source/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143
  at Java.Interop.JniEnvironment+InstanceMethods.CallIntMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniMethodInfo method) [0x00084] in /Users/builder/data/lanes/3819/5a02b032/source/Java.Interop/src/Java.Interop/Java.Interop/JniEnvironment.g.cs:11464
  at Android.Runtime.JNIEnv.CallIntMethod (System.IntPtr jobject, System.IntPtr jmethod) [0x00000] in /Users/builder/data/lanes/3819/5a02b032/source/monodroid/src/Mono.Android/JNIEnv.g.cs:186
  at Android.Support.V4.App.FragmentTransactionInvoker.CommitAllowingStateLoss () [0x00033] in <27c17fe440cf491ba8255bcefade6e02>:0
  at Xamarin.Forms.Platform.Android.AppCompat.MasterDetailContainer.Dispose (System.Boolean disposing) [0x00042] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\AppCompat\MasterDetailContainer.cs:130
  at Java.Lang.Object.Dispose () [0x00000] in /Users/builder/data/lanes/3819/5a02b032/source/xamarin-android/src/Mono.Android/Java.Lang/Object.cs:203
  at Xamarin.Forms.Platform.Android.AppCompat.MasterDetailPageRenderer.Dispose (System.Boolean disposing) [0x00046] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\AppCompat\MasterDetailPageRenderer.cs:192
  at Java.Lang.Object.Dispose () [0x00000] in /Users/builder/data/lanes/3819/5a02b032/source/xamarin-android/src/Mono.Android/Java.Lang/Object.cs:203
  at Xamarin.Forms.Platform.Android.AppCompat.Platform.SetPage (Xamarin.Forms.Page newRoot) [0x0003f] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\AppCompat\Platform.cs:226
  at Xamarin.Forms.Platform.Android.AppCompat.Platform.Dispose () [0x00010] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\AppCompat\Platform.cs:52
  at Xamarin.Forms.Platform.Android.FormsAppCompatActivity.OnDestroy () [0x0002f] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\AppCompat\FormsAppCompatActivity.cs:195
  at Android.App.Activity.n_OnDestroy (System.IntPtr jnienv, System.IntPtr native__this) [0x00009] in /Users/builder/data/lanes/3819/5a02b032/source/monodroid/src/Mono.Android/platforms/android-24/src/generated/Android.App.Activity.cs:2981
  at (wrapper dynamic-method) System.Object:b4f537f5-a711-449c-9bf3-d2540956cdc2 (intptr,intptr)
  --- End of managed Java.Lang.IllegalStateException stack trace ---
java.lang.IllegalStateException: Activity has been destroyed
    at android.support.v4.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1515)
    at android.support.v4.app.BackStackRecord.commitInternal(BackStackRecord.java:638)
    at android.support.v4.app.BackStackRecord.commitAllowingStateLoss(BackStackRecord.java:621)
    at md5b60ffeb829f638581ab2bb9b1a7f4f3f.FormsAppCompatActivity.n_onDestroy(Native Method)
    at md5b60ffeb829f638581ab2bb9b1a7f4f3f.FormsAppCompatActivity.onDestroy(FormsAppCompatActivity.java:80)
    at android.app.Activity.performDestroy(Activity.java:6866)
    at android.app.Instrumentation.callActivityOnDestroy(Instrumentation.java:1153)
    at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:4154)
    at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:4185)
    at android.app.ActivityThread.-wrap6(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1521)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6077)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)

iOS Device not recognized in Visual studio 15

$
0
0

Hi All,

I want to run my app in iPhone but my iOS Device not recognized in Visual studio 15

I am use windows 10 operating system.


Anyone know how to remove the blue line under Android ListView Group Headers?

$
0
0

Hi, has anyone successfully managed to remove the thin blue line under the Android Listview Group Headers?
I've tried a number of approaches, nothing appears to work, any help would really be appreciated.
Tx

Add custom row with buttons on Xamarin.Forms

Xamarin.Forms.Maps Click map to add pin

$
0
0

Hello all,

I am working on a work project In Xamarin forms (version 2.3.0.107) that requires fairly simple map functionality. The functions required are as follows:

On map load centre on users location and place a pin - This works fine using native maps

Allow user to click on the map and it clears the current pins and adds a new pin where user clicked - This is a pain, tried TK custom maps and the events for 'mapclick' don't register, also tried creating a subclass with an extension to add in a tap method, again this event never fired.

That's it, that's all I need, I've looked into creating custom renderers but it appears that XamarinMapOverlay can't be referenced in UWP, and I can't find any further references to it online.

Any help would be appreciated because this shouldn't have to be a stupidly complicated thing to implement, but every time I find a 'solution' it's either not finished, or doesn't work as expected.

Selecting all text in an entry field in a listview

$
0
0

Hi

I have checked a few forums but cant find a solution to this. On android, I want to select all the text when an entry field gets focused. From advice in forums, you put functionality in custom renderer which I did. This works for my Entry controls to start with, but when it is placed in a listview, once I start scrolling, the functionality is lost and the text is not selected when it get focus, even for ones that worked at start of the list. This happens for both types of CachingStrategy on the listview itself.

Here is my renderer. Interestingly, the actual style of the entry is fine, it just loses its on focus functionality

`
protected override void OnElementChanged(ElementChangedEventArgs e)
{
bool controlAlreadyExists = Control != null;

        // Important to do this base call after checking if control exists as this will create control if it doesnt exist
        base.OnElementChanged(e);

        // If control already exists either from changing orientation or scrolling listView then dont style again.
        if (!controlAlreadyExists)
        {
            if (Control != null)
            {
                // Round corners and set background colour to that of original Entry style
                var gd = new GradientDrawable();
                gd.SetCornerRadius(30);
                gd.SetColor(e.NewElement.BackgroundColor.ToAndroid());
                Control.SetBackground(gd);

                Control.SetPadding(20, 5, 20, 5);


                // Highlight all text when focusing
                Control.SetSelectAllOnFocus(true);
            }
        }

        // Need to hide the original control as the curved background means that original control colours would still appear in the corners
        e.NewElement.BackgroundColor = Color.Transparent;
    }

`

I have tried moving that SetSelectAllOnFocus line outside of the controlAlreadyExists block, and also tried checking the e.OldElement checks, but no such luck. Any advice / pointers?

Thanks

navigation bar causes space at the bottom of screen in ios

$
0
0

In my xamarin forms app, in ios when I login and show navigation bar on the dashboard page, it shows a space at the bottom of the screen in ios. When I hide the navigation bar that space is automatically removed. Can you please suggest a solution to show navigation bar as well as remove the space from the bottom.

Thanks in Advance.

Xamarin Forms - Webview - Remote Website - Load included javascript file

$
0
0

I have a simple Xamarin Forms project that has a WebView which is used to load an ASP.NET website on our intranet. Currently there is only a Android implementation in the solution.

The website being loaded includes several CSS and Javascript files. The CSS files are being linked via link rel tags, while the Javascript files are linked using script src tags.

I have put alert statements in a script on the page itself, as well as in the linked Javascript file. Using a browser on my computer, both alert statements show up, however in the WebView, only the alert for the page shows up.

I've also tried using the WebView.eval method to call a Javascript method in the linked file as well as one defined on the page itself. Calling the method defined on the page worked, but the one in the linked Javascript file didn't.

All that has lead me to the conclusion that for some reason the WebView isn't loading the Javascript files indicated by the script src tags.

From research I have done, there is mention of having to include the Javascript file itself in the Android and iOS projects, but those seemed to be for situations where the WebView source was being set to a constructed website, not pointing to an existing web site.

Here are samples of how the files are linked:
<link rel="stylesheet" href="/App_Themes/wms.min.css" />
<script src="/Scripts/wms.js">

I have tried using absolute paths, which didn't work either:
<script src="http://path.to.site/Scripts/wms.js">

What am I doing wrong? How do I get the the linked javascript files to load and be usable?

Using Office 365 API in Xamarin.Android

$
0
0

I am creating a sample for a talk: using Office 365 in Xamarin.Android, but I am having some errors, don´t know why :/

I got this:

"System.InvalidOperationException: An error occurred while processing this request. --->
Microsoft.OData.Client.DataServiceTransportException: Error: NameResolutionFailure --->
System.Net.WebException: Error: NameResolutionFailure\n
at System.Net.HttpWebRequest.EndGetResponse (IAsyncResult asyncResult) [0x00000]
in :0 \n at Microsoft.OData.Client.HttpWebRequestMessage.EndGetResponse (IAsyncResult asyncResult) [0x00000]
in :0 \n --- End of inner exception stack trace ---\n
at Microsoft.OData.Client.HttpWebRequestMessage.EndGetResponse (IAsyncResult asyncResult) [0x00000]
in :0 \n at Microsoft.OData.Client.ODataRequestMessageWrapper.EndGetResponse (IAsyncResult asyncResult) [0x00000]
in :0 \n at Microsoft.OData.Client.DataServiceContext.GetResponseHelper (Microsoft.OData.Client.ODataRequestMessageWrapper request, IAsyncResult asyncResult, Boolean handleWebException) [0x00000]
in :0 \n --- End of inner exception stack trace ---\n
at Microsoft.OData.Client.BaseAsyncResult.EndExecute[QueryResult] (System.Object source, System.String method, IAsyncResult asyncResult) [0x00000]
in :0 \n at Microsoft.OData.Client.QueryResult.EndExecuteQuery[Contact] (System.Object source, System.String method, IAsyncResult asyncResult) [0x00000]
in :0 \n--- End of stack trace from previous location where exception was thrown ---\n
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in :0 \n
at System.Runtime.CompilerServices.TaskAwaiter1[Microsoft.Office365.Exchange.Extensions.IPagedEnumerable1[Microsoft.Office365.Exchange.IContact]].GetResult () [0x00000]
in :0 \n at Microsoft.Office365.Exchange.Extensions.DataServiceContextWrapper+d__2d2[Microsoft.Office365.Exchange.Contact,Microsoft.Office365.Exchange.IContact].MoveNext () [0x00000] in <filename unknown>:0 \n--- End of stack trace from previous location where exception was thrown ---\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0 \n at System.Runtime.CompilerServices.TaskAwaiter1[Microsoft.Office365.Exchange.Extensions.IPagedEnumerable1[Microsoft.Office365.Exchange.IContact]].GetResult () [0x00000] in <filename unknown>:0 \n at Office365InXamarinApps.ViewModel.ContactsViewModel+<GetContacts>d__3.MoveNext () [0x000b5] in d:\\DevApps\\GitHub\\Office365InXamarinApps\\scr\\Office365InXamarinApps\\Office365InXamarinApps\\ViewModel\\ContactsViewModel.cs:44 \n--- End of stack trace from previous location where exception was thrown ---\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0 \n at System.Runtime.CompilerServices.TaskAwaiter1[System.Collections.Generic.IEnumerable`1[Microsoft.Office365.Exchange.IContact]].GetResult () [0x00000]
in :0 \n at Office365InXamarinApps.ViewModel.ContactsViewModel+d__0.MoveNext () [0x00030]
in d:\DevApps\GitHub\Office365InXamarinApps\scr\Office365InXamarinApps\Office365InXamarinApps\ViewModel\ContactsViewModel.cs:25 " string

and this

"Microsoft.OData.Core.ODataErrorException: Object reference not set to an instance of an object.
---> Microsoft.OData.Client.DataServiceQueryException: An error occurred while processing this request.
---> Microsoft.OData.Client.DataServiceClientException: {\"error\":{\"code\":\"ErrorInternalServerError\",\"message\":\"Object reference not set to an instance of an object.\",\"innererror\":{\"message\":\"Object reference not set to an instance of an object.\",\"type\":\"System.NullReferenceException\",\"stacktrace\":\"
at Microsoft.Exchange.Services.OData.Model.ContactSchema.<.cctor>b__2c(Entity e, PropertyDefinition ep, ServiceObject s, PropertyInformation sp)\r\n
at Microsoft.Exchange.Services.OData.Model.SimpleEwsPropertyProvider.GetProperty(Entity entity, PropertyDefinition property, ServiceObject ewsObject)\r\n
at Microsoft.Exchange.Services.OData.Model.ContactProvider.ItemTypeToEntity(ItemType itemType, IList1 properties)\\r\\n at Microsoft.Exchange.Services.OData.Model.ContactProvider.Find(String parentFolderId, ContactQueryAdapter queryAdapter)\\r\\n at Microsoft.Exchange.Services.OData.Model.FindContactsCommand.InternalExecute()\\r\\n at Microsoft.Exchange.Services.OData.ODataCommand2.Execute()\r\n
at Microsoft.Exchange.Services.OData.ODataTask.Execute(TimeSpan queueAndDelayTime, TimeSpan totalTime)\"}}}\n
at Microsoft.OData.Client.BaseAsyncResult.EndExecute[QueryResult] (System.Object source, System.String method, IAsyncResult asyncResult) [0x00000]
in :0 \n at Microsoft.OData.Client.QueryResult.EndExecuteQuery[Contact] (System.Object source, System.String method, IAsyncResult asyncResult) [0x00000]
in :0 \n --- End of inner exception stack trace ---\n
at Microsoft.OData.Client.QueryResult.EndExecuteQuery[Contact] (System.Object source, System.String method, IAsyncResult asyncResult) [0x00000]
in :0 \n at Microsoft.OData.Client.DataServiceRequest.EndExecute[Contact] (System.Object source, Microsoft.OData.Client.DataServiceContext context, System.String method, IAsyncResult asyncResult) [0x00000]
in :0 \n--- End of stack trace from previous location where exception was thrown ---\n
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in :0 \n at System.Runtime.CompilerServices.TaskAwaiter1[Microsoft.Office365.Exchange.Extensions.IPagedEnumerable1[Microsoft.Office365.Exchange.IContact]].GetResult () [0x00000] in :0 \n
at Microsoft.Office365.Exchange.Extensions.DataServiceContextWrapper+d__2d2[Microsoft.Office365.Exchange.Contact,Microsoft.Office365.Exchange.IContact].MoveNext () [0x00000] in <filename unknown>:0 \n --- End of inner exception stack trace ---\n at Microsoft.Office365.Exchange.Extensions.DataServiceContextWrapper+<ExecuteAsync>d__2d2[Microsoft.Office365.Exchange.Contact,Microsoft.Office365.Exchange.IContact].MoveNext () [0x00000]
in :0 \n--- End of stack trace from previous location where exception was thrown ---\n
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in :0 \n at System.Runtime.CompilerServices.TaskAwaiter1[Microsoft.Office365.Exchange.Extensions.IPagedEnumerable1[Microsoft.Office365.Exchange.IContact]].GetResult () [0x00000] in :0 \n
at Office365InXamarinApps.ViewModel.ContactsViewModel+d__4.MoveNext () [0x000d7] in d:\DevApps\GitHub\Office365InXamarinApps\scr\Office365InXamarinApps\Office365InXamarinApps\ViewModel\ContactsViewModel.cs:53 " string

Here:

public async Task<IEnumerable> GetContacts(Context context)
{ try
{
var client = await EnsureClientCreated(context);

            // Obtain first page of contacts
            var contactsResults = await (from i in client.Me.Contacts
                                         orderby i.DisplayName
                                         select i).Take(20).ExecuteAsync();

            return contactsResults.CurrentPage;
        }
        catch (Exception exception)
        {
            //todo handle this
            var error = exception.ToString();
        }
        return null;
    }</code>

in this file:
https://github.com/saramgsilva/Office365InXamarinApp/blob/master/scr/Office365InXamarinApps/Office365InXamarinApps/ViewModel/ContactsViewModel.cs

The code is here: https://github.com/saramgsilva/Office365InXamarinApp


I keep getting XamlFilePathAttribute class not found error when modifying Xaml files

$
0
0

This attribute was introduced in November. Somehow it get's injected in my generated cs files for my xaml views but the compiler has no clue where to find the attribute. I suppose I have a versioning problem. Is it possible to get the versions where this was introduced in tools and in the libraries please?

Xaml Compilation - Object reference not set to an instance of an object

$
0
0

When trying to use XAML Compilation i always get this issue when building:

1> Module: TestApp.dll
1> Resource: TestApp.Page1.xaml...
1> Parsing Xaml... done.
1> Replacing Page1.InitializeComponent ()... failed.
1> C:\ProyectosInvestigacion\TestApp\TestApp\TestApp\TestApp.Page1.xaml : error : Object reference not set to an instance of an object.
1> at Xamarin.Forms.Build.Tasks.SetNamescopesAndRegisterNamesVisitor.CreateNamescope()
1> at Xamarin.Forms.Build.Tasks.SetNamescopesAndRegisterNamesVisitor.Visit(RootNode node, INode parentNode)
1> at Xamarin.Forms.Xaml.RootNode.Accept(IXamlNodeVisitor visitor, INode parentNode)
1> at Xamarin.Forms.Build.Tasks.XamlCTask.Compile()

I've done a simple TestProject in which i added one Xaml page and configured it to compile:

    [XamlCompilation(Xamarin.Forms.Xaml.XamlCompilationOptions.Compile)]
    public partial class Page1 : ContentPage
    {
        public Page1()
        {
            InitializeComponent();

        }
    }

And the Xaml here:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="TestApp.Page1">
  <Label x:Name="lblText" Text="{Binding MainText}" VerticalOptions="Center" HorizontalOptions="Center" />
</ContentPage>

This always throws "Object reference not set to an instance of an object" on the Error List using Visual Studio 2013, Xamarin Forms 2.1.0.6529
I'm attaching the whole solution so anyone can reproduce this error.

Is there a known way to get Xaml Compilation working?

Make my app "shareable"

$
0
0

Hi there !!

I'm developing an app on Xamarin Forms (Android/iOS). My app needs to be shareable for some types of file (as documents and images). I mean that from File Manager I can select a file and then press the share button and select my app to "share" the file. How can I do that ? I was looking at Share Plugin but I'm not sure that it is what I'm looking for.

Thanks !

How to add an offset between entry field and entry's keyboard?

$
0
0

Hi,

When the user hit the entry field, the keyboard will show up right close to entry field line/box. I want to add extra offset between the keyboard and the entry field line/box so the user can see a label I added underneath the entry field.

-iKK

How to confirm SMS send/receive in Xamarin Forms?

$
0
0

Hi,

What I need to do to confirm that the user sent the SMS successfully and when the message return from specific number, how can I count the received SMS details?

Any examples?

-IKK

Viewing all 91519 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>