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

TabbedPage With ToolbarItems Left And Right position in iOS.

$
0
0

Hello Gyus!!!!

I am using the custom renderer found here in the forum.

The problem is that the first time you open the screen above the buttons are rendered correctly, but go to another tab the toolbar buttons back to her home state.

<TabbedPage.ToolbarItems>


</TabbedPage.ToolbarItems>

<br /> [assembly: ExportRenderer(typeof(ContentPage), typeof(ContentPageRenderer))]<br /> namespace Pdv.Presentation.Mobile.iOS.Renderers<br /> {</p> <p>public class ContentPageRenderer : PageRenderer<br /> {<br /> public override void ViewWillAppear(bool animated)<br /> {<br /> base.ViewWillAppear(animated);</p> <pre><code> var contentPage = this.Element as ContentPage; if (contentPage == null || NavigationController == null) return; var itemsInfo = contentPage.ToolbarItems; var navigationItem = this.NavigationController.TopViewController.NavigationItem; var leftNativeButtons = (navigationItem.LeftBarButtonItems ?? new UIBarButtonItem[] { }).ToList(); var rightNativeButtons = (navigationItem.RightBarButtonItems ?? new UIBarButtonItem[] { }).ToList(); var newLeftButtons = new UIBarButtonItem[] { }.ToList(); var newRightButtons = new UIBarButtonItem[] { }.ToList(); rightNativeButtons.ForEach(nativeItem => { // [Hack] Get Xamarin private field "item" var field = nativeItem.GetType().GetField("_item", BindingFlags.NonPublic | BindingFlags.Instance); if (field == null) return; var info = field.GetValue(nativeItem) as ToolbarItem; if (info == null) return; if (info.Priority == 0) { if (!leftNativeButtons.Any()) newLeftButtons.Add(nativeItem); } else newRightButtons.Add(nativeItem); }); leftNativeButtons.ForEach(nativeItem => { newLeftButtons.Add(nativeItem); }); navigationItem.RightBarButtonItems = newRightButtons.ToArray(); navigationItem.LeftBarButtonItems = newLeftButtons.ToArray(); } }

}

I need the renderer control maintains its state set up this custom.


Is there any way to fix Xamarin.Forms not support SVG or NinePatch images?

$
0
0

Hi guys
Thought Xamarin.Forms does't support SVG or NinePatch images.Is there any feathers or plugins to fix it?Free is the best.
Any recommand is helpful.Thanks,guys.

"Command" called on iOS, but not on Android

$
0
0

Hello,

I'm facing a strange issue in Xamarin.Forms, using MvvmLight's RelayCommand and Xamarin's Button.Command property.

I'm doing something very simple (I kept relevant code):

<ContentPage BindingContext="{Binding SubscribeOrLoginViewModel, Source={StaticResource ViewModelLocator}}">
    <Button Command="{Binding SomeCommand}" />
</ContentPage>
public class MyViewModel : ViewModelBase
{
    public ICommand SomeCommand {
        get { return new RelayCommand(() => System.Diagnostics.Debug.WriteLine("Hello!")); }
    }
}

On iOS, there's no problem. That just works. However, on Android, nothing happens. To be more precise, the binding works (MyViewModel.SomeCommand.get is called, so the command is created), but the command itself is not executed. I put WriteLines, breakpoints, etc, nothing. No errors, no crashes.

I changed the linker settings and tried on 2 PCs, nothing.

What could be the causes of such a behavior?

Edit: broken with Xamarin's Command too, not only MvvmLight's RelayCommand.

Issue on DataTemplate Null Exception

$
0
0

Hi
In a ListView DataTemplate I use an event handler like that to limit the char number.

**
public class NuovoCliente_IndSpedizItemCell : ViewCell
{
.....
Entry txtCap = new Entry()
{
HorizontalOptions = LayoutOptions.FillAndExpand
};

        txtCap.SetBinding<GEST_Clienti_Anagrafica_IndirizziConIsSelected>(Entry.TextProperty, x => x.Cap);

......
txtCap.TextChanged += Delegates.AutoUnsubscribe((sender, args) =>
{

        if (sender == null)
            return;
        string _text = txtCap.Text;
        if (_text.Length > 5)
        {
            _text = _text.Remove(_text.Length - 1);
            txtCap.Text = _text;
        }
            )
        };**

When I delete all the items from the related List I get a null exception error.

How can I detach all events correctly inside the DataTemplate ? I've used Behaviour, OnDisepparing and I get the same issue.
Tnx and excuse me for my stupid question.

HttpClient in PCL on iOS stopped working for me. TaskCancelledException thrown.

$
0
0

This is a Xamarin.Forms app. So this HttpClient call is in PCL. It's being called from a Timer firing on the iOS side.
It worked fine in previous version. It worked fine on android. App is sitting idle and it will randomly throw that exception from the HTTPClient. It's not every time. The timeout is 15 seconds but it doesn't appear to be taking 15 seconds to throw that. It's throwing it nearly instantly.

Tried reverting Xamarin.iOS version and it still seems to happen. Cleaned everything bin/obj etc. Code related to it hasn't changed and the previous build of the app before updating works fine. Shouid I try reverting xamarin studio on mac also? What updates the PCL lib behind the scenes? Xamarin.iOS?

Code:

using (HttpClient client = new HttpClient() { Timeout = Ti  meSpan.FromMilliseconds(15000) })
{
     var result = await client.GetAsync(url); // THROWING TaskCancelledException HERE
}

Stack:

  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0002d] in /Users/builder/data/lanes/3412/3cf8aaed/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:179
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in /Users/builder/data/lanes/3412/3cf8aaed/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in /Users/builder/data/lanes/3412/3cf8aaed/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128
  at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () [0x00000] in /Users/builder/data/lanes/3412/3cf8aaed/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:357
  at System.Net.Http.HttpClientHandler+<SendAsync>c__async0.MoveNext () [0x004af] in /Library/Frameworks/Xamarin.iOS.framework/Versions/9.8.1.4/src/mono/mcs/class/System.Net.Http/System.Net.Http/HttpClientHandler.cs:382
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/3412/3cf8aaed/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00027] in /Users/builder/data/lanes/3412/3cf8aaed/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:176
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in /Users/builder/data/lanes/3412/3cf8aaed/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in /Users/builder/data/lanes/3412/3cf8aaed/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in /Users/builder/data/lanes/3412/3cf8aaed/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:535
  at System.Net.Http.HttpClient+<SendAsyncWorker>c__async0.MoveNext () [0x000a9] in /Library/Frameworks/Xamarin.iOS.framework/Versions/9.8.1.4/src/mono/mcs/class/System.Net.Http/System.Net.Http/HttpClient.cs:276
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/3412/3cf8aaed/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00027] in /Users/builder/data/lanes/3412/3cf8aaed/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:176
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in /Users/builder/data/lanes/3412/3cf8aaed/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in /Users/builder/data/lanes/3412/3cf8aaed/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128
  at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () [0x00000] in /Users/builder/data/lanes/3412/3cf8aaed/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:357
  at MyCompany.Mobile.Services.ReachabilityService+<CanReachUrlCore>c__async2.MoveNext () [0x000b8] in /Users/shane/GitHub/MyCompany.Mobile/MyCompany.Mobile/Services/ReachabilityService.cs:33

Resizing Children in AbsoluteLayout on OnSizeAllocated

$
0
0

I made a control, that inherits AbsoluteLayout with the goal to position n children elements in a certain way.
It sets custom x and y positions and custom width and an AutoSized height (up to a certain maximum height).
Basically, my control works like this:

public class ResponsiveLayout : AbsoluteLayout
    {
    protected override void OnSizeAllocated(double width, double height)
        {
        foreach (var control in Children)
                {
            var size = control.Measure(elementWidth, AutoSize);
            var measuredHeight = size.Request.Height;
             if (MaxPanelHeight != AutoSize && measuredHeight > MaxPanelHeight)
                measuredHeight = MaxPanelHeight;

            SetLayoutBounds(control, new Rectangle(posX1, posY1, elementWidth, measuredHeight));
        }
    }
}

Ideally, this should be called every time the Children changed (added/removed) and every time the size of the control changes (the phone changes orientation / the Window changes size).

The problem is, this get's called way too often. Every window resize, OnSizeAllocated get's called roughtly 3 times per child control - which causes quite a performance issue on Android. For other events (measure, invalidated, and so on) it's the same deal.

Is there a way to just call this once and make it work?
Like, is there an event that fires only when the last child did invalidate or something?

The type or namespace name 'XmlElement' does not exist in the namespace 'System.Xml'

$
0
0

Someone asked a similar question and has not got any response. Let me try again and provide more details.
A PCL was created to be used by Xamarin Forms projects with the following targets:

I added a service reference (Add >Service Reference... > Enter a WSDL file address > OK). Everything worked fine so far. When the PCL is built, hundreds of the follow errors are generated:
Reference.cs(9732,27,9732,37): error CS0234: The type or namespace name 'XmlElement' does not exist in the namespace 'System.Xml' (are you missing an assembly reference?)

Could anyone offer a tip on how to remedy this?

Navigation from a Tabbed Page with a Notification

$
0
0

Hi,

I have an application where my main page is a tabbed page. I am trying to navigate to a content page when a notification arrives. I have my event handler ready and it gets hit when the notification arrives. This event handler function is inside my App.cs inside the shared project. So, I am trying to navigate from there as below.

Device.BeginInvokeOnMainThread(() =>
{
//MainPage.Navigation.PushAsync(new InBoundCallPage());
MainPage.Navigation.PushModalAsync(new InBoundCallPage());
});

But, here the "PushModalAsync" says it is an unknown member when I put a break point over there. I am not getting why this is happening. Please help.

Thanks,
sk


Entry view with Keyboad sets to Numeric des not work

$
0
0

Hello:

I have this definition in my xaml:

But when you start typeing the regular keyboard appears, not the numeric only. Is this a bug in Android or I am missing something.

Thanks in advanced.

David

Realese para android 6.0

$
0
0

I have a question, do one application in Xamarin forms, it works fine but when installing it on an actual device with android 6.0, the APPLICATION stops, when to debug shows no errors and runs well, Note: the application the I try to install from SD memory, I need to add a permit or something ???.

Sorry for my bad English.

How to play an youtube video through using youtube url in xamarin forms

$
0
0

Hi everyone, i want play an video through using youtube url. Here if i use webview its playing in youtube but again its not coming to My App.Is there any other way to do this.
can someone help me in this plz. source code will be more helpful. thanks in advance

Listview GroupHeaderTemplate

$
0
0

Is it possible to bind to a listview with classes like this? All examples of listview group headers have had the class something like :

public class Test : ObservableCollection<TestTwo>.

but I want my classes to look like this, is it possible? Right now Xamarin Forms can't find any of the properties on my class.

    public class Test
    {
        public string ItemName { get; set; }

        public ObservableCollection<TestTwo> List { get; set; }

        public Test () {

            List = new ObservableCollection<TestTwo> ();

        }
    }

    public class TestTwo
    {
        public string Count { get; set; }
    }

How to display grouped items in ListView from collection which is already grouped?

$
0
0
public class Per
    {
        public int Id { get; set; }
        public string Name { get; set; }

        public ObservableCollection<Quot> Quots { get; set; }
    }

    public class Quot
    {
        public int Id { get; set; }
        public string Statement { get; set; }

        public int PersonId { get; set; }
        public Per Per { get; set; }
    }

ListView should display grouped data from following collection:

ObservableCollectiion<Per> Persons = new ObservableCollectiion<Per>();

PS Note: I already know how to display grouped items from collection which is not already grouped (using LINQ's GroupBy method).
E.g: List <Quot>

the type or namespace name 'ContentPage' could not be found

$
0
0

I am currently doing the Self-Guided XAM120 - into to Xamarin.Forms.
Topic (Rstructure) Exercise 2 - Restructure the Boilerplate Code

It says to "Create a new class in a new file named MainPage that derives from ContentPage. Take the existing code which creates the ContentPage and move it to the new class."

I created the new class and added the following code :

// MainPage.cs
public class MainPage : ContentPage
{
    public MainPage()
    {
        Content = new StackLayout
        {
            VerticalOptions = LayoutOptions.Center,
            Children = {
                new Label {
                    HorizontalTextAlignment = TextAlignment.Center,
                    Text = "Welcome to Xamarin Forms!"
                }
            }
        };
    }

}

But when I debug this error comes out :
"Error CS0246: The type or namespace name 'ContentPage' could not be found. Are you missing 'Xamarin.Forms' using directive? (CS0246) (PhoneWord)"

Any idea what I am doing wrong here?

Need Help AutoComplete XLabs(Newbie to Xamarin)

$
0
0

Hello Community,

I am a newbie to Xamarin Platform and need help with the AutoComplete Control from XLabs. Can somebody share a small demo app build showing working of AutoComplete.

Till now I have gone through the XLab xaml sample for AutoCompleteView but it's codebehind part is missing. Please help me with that.

TIA.


Custom Keyboard with Xamarin Forms, all working except position of keyboard

$
0
0

Im trying to create a custom numeric keyboard for an EditText which is in a listview I have rendering as a native listview but is running within a Xamarin Forms application. I have the keyboard working as per this sample

http://mono-for-android.1047100.n5.nabble.com/Creating-a-Softkeyboard-with-mono-td5710871.html

However if you see the screen shot attached line 124. The keyboard ends up getting shown immediately under the actionbar and is overlaying the Xamarin Forms Page. I need it docked to the bottom. Does anyone know how this one Activity Xamarin Forms creates works exactly? I also have had an attempt at doing a custom renderer for this keyboard but am facing other challenges.

Can't debug android

$
0
0

Hi, I have a Xamarin.Forms app. I am using Visual Studio 2015.
The debugger in android fail 90% of times. If I hit debug button, it compiles and deploy but the app does not launch in the device.
Is like it is only deploying the solution, because if I launch app manually in device, the last version is installed.

I am not getting any failure log or message.

Rare thing is that sometimes, I don't know how, I am able to debug perfectly the solution.

Someone have this issue before?
Thanks for any help

How to show videos in Visual Studio Android Emulator?

$
0
0

I have a video view in my project that plays videos . when I use Visual Studio Android Emulator, it only shows a black screen and i can hear the audio . So what is the way to show these videos ? It is worth to mention that other emulators play video with almost no issue .

Multiple errors when creating Xamarin.Forms - Blank Xaml App (Xamarin.Forms Portable) or Android App

$
0
0

Hello,
I using Windows 10 and am trying to create a Xamarin.Forms - Blank Xaml App (Xamarin.Forms Portable) project for the first time. I have Visual Studio 2015 Enterprise Update 3 installed and have tried uninstalling, reinstalling, and repairing multiple times.

When I create a project, I get the following errors:
"The name 'InitializeComponent' does not exist in the current context"
"Error encountered while loading the project. Some project features, such as full solution analysis for the failed project and projects that depend on it, have been disabled" - for App, Droid, UWP, WinPhone, Windows, and iOS
"The XamlCTask task failed unexpectedly..." - for UWP, WinPhone, Windows, and iOS

I tried this on my work computer and home computer and I had the same issues with both.

I have tried updating Xamarin.Forms nuget to the latest version and the created 36 errors with Droid. I also tried going to c:/users/[YOURNAME]/AppData/Local. Delete the Xamarin folder and that did not solve the issue.

I tried creating other Visual Studio projects that did not involve Xamarin and did not have any issues with those. I know the issue is with Xamarin (probably something with Android) itself, but I don't think that there is anything that I am missing from the install. I tried installing it by first installing Visual Studio, then going to Modify and adding Cross Platform. That didn't work, so I uninstalled then downloaded the Xamarin Installer. I had the same issues with both.

I created a blank Android App and that give me the warning - "aapt.exe" exited with code - 1073741849".
A blank app for iPhone does not give any errors or warnings.
Windows Phone does not give any errors or warnings either.

Any ideas of what I should check for so I can get this working?

Push a page on the navigation stack when device orientation changes

$
0
0

I'm trying to push a new page when device orientation changes to landscape. I wanted to do this in a base content page like so:

        private async void BasePage_OnSizeChanged(object sender, EventArgs e)
        {
            var navigationPage = App.Current.MainPage as NavigationPage;
            if (this == navigationPage.CurrentPage)
            {
                if (Helpers.GetScreenOrientation() == Enums.ScreenOrientation.Landscape)
                {
                    await navigationPage.PushAsync(new CustomPage());
                }
            }
        }

However, I'm getting an error:

Collection was modified; enumeration operation may not execute. (System.InvalidOperationException)
  at System.ThrowHelper.ThrowInvalidOperationException (System.ExceptionResource resource) [0x00000] in /Users/builder/data/lanes/1381/3afb4af5/source/maccore/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/mscorlib/system/throwhelper.cs:99
  at System.Collections.Generic.List`1+Enumerator[T].MoveNextRare () <0x10021c180 + 0x0002f> in <filename unknown>:0
  at System.Collections.Generic.List`1+Enumerator[T].MoveNext () <0x10021c0b0 + 0x0009f> in <filename unknown>:0
  at Xamarin.Forms.Page.LayoutChildren (System.Double x, System.Double y, System.Double width, System.Double height) [0x00119] in C:\BuildAgent\work\aad494dc9bc9783\Xamarin.Forms.Core\Page.cs:167
  at Xamarin.Forms.Page.UpdateChildrenLayout () [0x000d0] in C:\BuildAgent\work\aad494dc9bc9783\Xamarin.Forms.Core\Page.cs:252

  at Xamarin.Forms.Page.OnSizeAllocated (System.Double width, System.Double height) [0x0000f] in C:\BuildAgent\work\aad494dc9bc9783\Xamarin.Forms.Core\Page.cs:233
  at Xamarin.Forms.VisualElement.SizeAllocated (System.Double width, System.Double height) [0x00000] in C:\BuildAgent\work\aad494dc9bc9783\Xamarin.Forms.Core\VisualElement.cs:629
  at Xamarin.Forms.Page.ForceLayout () [0x00000] in C:\BuildAgent\work\aad494dc9bc9783\Xamarin.Forms.Core\Page.cs:144
  at Xamarin.Forms.Page.Xamarin.Forms.IPageController.set_ContainerArea (Xamarin.Forms.Rectangle value) [0x0001d] in C:\BuildAgent\work\aad494dc9bc9783\Xamarin.Forms.Core\Page.cs:99
  at Xamarin.Forms.Platform.iOS.NavigationRenderer.ViewDidLayoutSubviews () [0x000c4] in C:\BuildAgent\work\aad494dc9bc9783\Xamarin.Forms.Platform.iOS\Renderers\NavigationRenderer.cs:182
  at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
  at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntP
tr delegate) [0x00005] in /Users/builder/data/lanes/1381/3afb4af5/source/maccore/src/UIKit/UIApplication.cs:79
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0001c] in /Users/builder/data/lanes/1381/3afb4af5/source/maccore/src/UIKit/UIApplication.cs:62
  at NewTest.iOS.Application.Main (System.String[] args) [0x00001] in C:\Users\xyz\Documents\Visual Studio 2015\Projects\NewTest\NewTest\NewTest.iOS\Main.cs:17
Viewing all 58056 articles
Browse latest View live


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