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

Best way to display dynamic text on bitmap image

$
0
0

Hi,
I'm a complete newbie to mobile development, so please bare with me.

I've designed a Xamarin Forms Cross Platform project in Visual Studio 2015 Community Edition (targeting only Android at this point) which is an interface to a CDU (Control Display Unit) in the X-Plane 10 simulator. The app consists of a single page which contains a bitmap image of the CDU unit from a Boeing 737-300. I am using an AbsoluteLayout to position all the buttons on top of the "virtual" buttons on the image. The "virtual display" of the CDU is currently made up of a whole bunch of labels to display the various data elements which is returned from the simulator via the network in real time, so the labels are bound to data returned via a TCP socket.

The app is working 100%, but I'm not happy with the limitations of the text displayed inside the labels... I need more control when displaying the CDU screen text.
Here's a screenshot of my app running on my "cheapo" Acer Iconia B1 tablet...
image

I would like the text to occupy the whole label without any "padding" to the edges of the label. Look at the highlighted line displaying "551"...
I would also like to be able to highlight a subset of characters within a single "view"/label. For example: "MOD RTE LEGS" is the data returned from the sim and I need to display the MOD highlighted and then the rest as normal green text.
I would also like to be able to specify letter spacing and use a custom "monospaced" font.
Here are two images from the actual simulator showing how it should be displayed...
image image

So what are my options? Will it be possible to use the graphics API or maybe even SkiaSharp with custom renderers to handle the display portion of the CDU?

Any help or advice would be greatly appreciated.
Thanks, Jean.


Simplest way to draw a single pixel on Xamarin Forms ContentPage?

$
0
0

Hi,
maybe with SkiaSharp (in Xamarin Forms) @mattleibow?
Or can i detect touch event and draw a BoxView 1x1? (but i hope drawing 500 boxview will decrease app performance?).
I use SignaturePad, but i have to do it in UWP, and this component doesn't support it.

Thank you for any suggest!

Lewix

Xamarin.Forms.Platform.MacOS

How to do a HTTP Request every few minutes when app sleeps / user leaves app

$
0
0

Hey,

How can I do a HTTP request every 5 minutes, if the user leaves the app / locks his phone or something similar (= if the App is not active on the screen)?
My first (probably stupid) idea was, to put a timer inside the protected override void OnSleep() method, but I am pretty sure that there is a better way.
Can somebody provide me some information / links to get started with that? Even a proper term for this problem would help me :)

Cheers!

NavigationPage.TitleIcon not displaying on android project

$
0
0

I am having problem with NavigationPage.TitleIcon that is displaying my logo.png on my ios project but not displaying the logo on android project.

I have my xaml like below:

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms"
             prism:ViewModelLocator.AutowireViewModel="True"
             xmlns:behav="clr-namespace:Uno.Behaviors;assembly=Project"
             x:Class="Uno.Views.Page"
             NavigationPage.HasBackButton="false"
              NavigationPage.TitleIcon="logo.png">
</ContentPage>

and also I have kept the png file in ios Resources and android Resources->drawable directory.

Can anybody help me what I have done wrong there?

How to add split function to a label in listview?

$
0
0

I have to bind data which is separated by a comma separator. I need to used split function to one label to bind data and i want to separate it by comma(,). Can any one please tell me about this. Is there any other option to resolve this issue??
here is my sample xaml code...

<ListView.ItemTemplate>





In question label i need to separate data by comma(,)...

I need chip Control Like gmail app

I create a new Xamarin.Forms project,When I want to add a xaml contentpage,but it throw below error


Xamarin Forms Display image in default gallery application

$
0
0

Hi,

i have a requirement to display image in the gallery application.

in android, i could easily done using below piece of code

Intent intent = new Intent(); intent.AddFlags (ActivityFlags.NewTask); intent.SetAction(Intent.ActionView); intent.SetDataAndType(Android.Net.Uri.Parse(imageURL), "image/*"); Application.Context.StartActivity ( intent );

is there any similar way in ios ?

thanks in advance.

Xamarin.Forms ContentPage in .xaml file, in combination with ReSharper intellisense not working

$
0
0

Hi,
I'm experiencing the following problem:

  • Clean Xamarin.Forms Shared Project in Visual Studio using ReSharper (intellisense working)
  • Adding Xamarin.Forms ContentPage XAML to the project from Visual Studio template => Intellisense not working (e.g. "cannot resolve symbol 'System'")

I already searched through google and numerous Xamarin forums. All solutions presented there were futile:

  • setting the Build Action of the XAML file to "Embedded Resource" => it was already set.
  • setting the Custom Tool of the XAML file form "Build" to "UpdateDesignTimeXaml" => it already was set.
  • correcting the namespace of the x:Class in the XAML file => it already was correct.
  • updating Xamarin.Forms and everything else => it is uptodate (Xamarin.Forms 2.3.2.127)
  • cleaning ReSharper cache
  • deleting and restarting obj, and bin dirs in solution
  • deleting .suo file

The only thing that helped so for until the restart of Visual Studio was to change the Build Action of the XAML to something else and back to "Embedded Resource". But after a restart the intellisense again did not work.

For the moment I solved the Problem by deleting the XAML file again but that cannot be the solution. Can anyone help me with this problem? It is quiet a dealbreaker for Xamarin.Forms.

Best Regards!

Using TPM on Xamarin.Forms project

$
0
0

Hello everyone,

I've been working on a project requiring Trusted Platform Modules on Windows 8 and Windows 10 (UWP) for a moment. I would like to use the Non-Volatile storage functionality of those chips in order to store some cryptographic keys.

I wasn't able to find any implementations of TPM on Xamarin so i am using an abstract class and platform specific code.

I use TSS.MSR library in order to perform actions with a TPM however my TPM is blocking some commands like NvDefineStorage or even Hash.

Exception raised by NvDefineStorage on UWP project

Tpm2Lib.TpmException: Error {None} was returned for command NvDefineSpace.
Details:
[Code=TpmRc.None],[RawCode=0x80280400,2150106112]
[ErrorEntity=Unknown], [ParmNum=0]
[ParmName=Unknown]
at Tpm2Lib.Tpm2.ProcessError(TpmSt responseTag, UInt32 responseParamSize, TpmRc resultCode, TpmStructureBase inParms)
at Tpm2Lib.Tpm2.DispatchMethod(TpmCc ordinal, TpmStructureBase inParms, Type expectedResponseType, TpmStructureBase& outParms, Int32 > numInHandlesNotUsed, Int32 numOutHandlesNotUsed)
at Tpm2Lib.Tpm2.NvDefineSpace(TpmHandle authHandle, Byte[] auth, NvPublic publicInfo)
at TestNvStorage.App.StoreData(Byte[] data)

It looks like some commands are blocked by Windows or GroupPolicies (https://technet.microsoft.com/en-us/library/cc771635(v=ws.11).aspx) so i specified in those policies to ignore the local blocked command list and also ignore the default blocked list (there is no command in the list of blocked commands).

I'm not able to access to command management in tpm.msc (if you have any idea why, it could help)

I also don't have TPM registry key in HKEY_LOCAL_MACHINE\SOFTWARE\Policies\WindowsTPM so it also can be a reason to my issues.

Now the TPM commands shouldn't be blocked anymore nevertheless i'm still not able to perform those commands.

There is my UWP code:

UWP application (Not Working with TPM)

using System;
using System.Diagnostics;
using System.Linq;
using Windows.ApplicationModel;
using Windows.ApplicationModel.Activation;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;
using Tpm2Lib;

namespace TestNvStorage
{
sealed partial class App : Application
{
public static int indexTMPSlot = 3001;
public static AuthValue nvAuthValue = new AuthValue(new byte[] { 3, 4, 5, 6, 7, 8, 9 });

    public static void StoreData(byte[] data)
    {
        Tpm2Device tpmDevice;
        tpmDevice = new TbsDevice();
        tpmDevice.Connect();
        var tpm = new Tpm2(tpmDevice);

        var ownerAuth = new AuthValue();
        TpmHandle nvHandle = TpmHandle.NV(indexTMPSlot);
        tpm[ownerAuth]._AllowErrors().NvUndefineSpace(TpmHandle.RhOwner, nvHandle);

        AuthValue nvAuth = nvAuthValue;

        tpm[ownerAuth].NvDefineSpace(TpmHandle.RhOwner, nvAuth,
        new NvPublic(nvHandle, TpmAlgId.Sha1,
            NvAttr.Authwrite | NvAttr.Authread,
            new byte[0], 32));

        tpm[nvAuth].NvWrite(nvHandle, nvHandle, data, 0);
        tpm.Dispose();
        Debug.WriteLine(String.Format("Data Stored:\t{0}", Convert.ToBase64String(data)));
    }

    public static byte[] ReadData(int tailleData)
    {
        Tpm2Device tpmDevice;
        tpmDevice = new TbsDevice();
        tpmDevice.Connect();
        var tpm = new Tpm2(tpmDevice);

        TpmHandle nvHandle = TpmHandle.NV(indexTMPSlot);

        AuthValue nvAuth = nvAuthValue;

        byte[] newData = tpm[nvAuth].NvRead(nvHandle, nvHandle, (ushort)tailleData, 0);

        tpm.Dispose();
        Debug.WriteLine(String.Format("Data retreived:\t{0}", Convert.ToBase64String(newData)));
        return newData;
    }

    public static void ClearTpmNvSpace()
    {
        Tpm2Device tpmDevice;
        tpmDevice = new TbsDevice();
        tpmDevice.Connect();
        var tpm = new Tpm2(tpmDevice);

        TpmHandle nvHandle = TpmHandle.NV(indexTMPSlot);
        var ownerAuth = new AuthValue();
        tpm[ownerAuth]._AllowErrors().NvUndefineSpace(TpmHandle.RhOwner, nvHandle);
        tpm.Dispose();
        Debug.WriteLine("TPM cleaned");
    }

   public App()
    {
        this.InitializeComponent();

        byte[] nvData = new byte[] { 10, 1, 22, 33, 14, 55, 6, 37, 8, 200, 1, 2, 3, 4, 5, 6, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 2, 3, 4, 5, 6 };
        StoreData(nvData);
        byte[] newBytes = ReadData(nvData.Length);
        Debug.WriteLine(String.Format("Data Matching:\t{0}", nvData.SequenceEqual(newBytes)));
        ClearTpmNvSpace();
    }

}

}

I had some advices from Paul England to add Shared User Certificates in my UWP manifest capabilities so i followed the instructions. I also tried to run Visual studio to run my debug as Administrator but still not able to make it work on my UWP project.

Funny thing is i'm able to run my code (exactly the same) on a basic Windows console application flawlessly.

Windows Console application (Working with TPM)

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tpm2Lib;

namespace TestNvStorageConsole
{
class Program
{
public static int indexTMPSlot = 3001;
public static AuthValue nvAuthValue = new AuthValue(new byte[] { 3, 4, 5, 6 ,7,8,9});

    public static void StoreData(byte[] data)
    {
        Tpm2Device tpmDevice;
        tpmDevice = new TbsDevice();
        tpmDevice.Connect();
        var tpm = new Tpm2(tpmDevice);

        var ownerAuth = new AuthValue();
        TpmHandle nvHandle = TpmHandle.NV(indexTMPSlot);
        tpm[ownerAuth]._AllowErrors().NvUndefineSpace(TpmHandle.RhOwner, nvHandle);

        AuthValue nvAuth = nvAuthValue;

        tpm[ownerAuth].NvDefineSpace(TpmHandle.RhOwner, nvAuth,
        new NvPublic(nvHandle, TpmAlgId.Sha1,
            NvAttr.Authwrite | NvAttr.Authread,
            new byte[0], 32));

        tpm[nvAuth].NvWrite(nvHandle, nvHandle, data, 0);
        tpm.Dispose();
        Debug.WriteLine(String.Format("Data Stored:\t{0}", Convert.ToBase64String(data)));
    }

    public static byte[] ReadData(int tailleData)
    {
        Tpm2Device tpmDevice;
       tpmDevice = new TbsDevice();
        tpmDevice.Connect();
        var tpm = new Tpm2(tpmDevice);

        TpmHandle nvHandle = TpmHandle.NV(indexTMPSlot);

        AuthValue nvAuth = nvAuthValue;

        byte[] newData = tpm[nvAuth].NvRead(nvHandle, nvHandle, (ushort)tailleData, 0);

        tpm.Dispose();
        Debug.WriteLine(String.Format("Data retreived:\t{0}", Convert.ToBase64String(newData)));
        return newData;
    }

    public static void ClearTpmNvSpace()
    {
        Tpm2Device tpmDevice;
        tpmDevice = new TbsDevice();
        tpmDevice.Connect();
        var tpm = new Tpm2(tpmDevice);

        TpmHandle nvHandle = TpmHandle.NV(indexTMPSlot);
        var ownerAuth = new AuthValue();
        tpm[ownerAuth]._AllowErrors().NvUndefineSpace(TpmHandle.RhOwner, nvHandle);
        tpm.Dispose();
        Debug.WriteLine("TPM cleaned");
    }

    static void Main(string[] args)
    {
        byte[] nvData = new byte[] {10, 1, 22, 33, 14, 55, 6, 37, 8, 200, 1,2,3,4,5,6,2,3,4,5,1,2,3,4,5,6,2,3,4,5,6};
        StoreData(nvData);
        byte[] newBytes = ReadData(nvData.Length);
        Debug.WriteLine(String.Format("Data Matching:\t{0}",nvData.SequenceEqual(newBytes)));
        ClearTpmNvSpace();
    }
}

}

If anyone does have an idea to solve this issue or maybe another method to use TPM with Xamarin, I'm open to suggestions.

Tanguy

Listview With Image Thumbnails Not Being Shown When Added.

$
0
0

I'm trying to implement a listview that has a image in it where the image is bound to a thumbnail property as using the raw photos just kills performance of the listview. This thumbnail property resizes the main picture and then adds it to a thumbnail cache - therefore when the thumbnail property is called again for any photo - if it exists - it just grabs it from the cache. This works how I expect when the list loads up (and there are images already on the device) - however when I add an image to the list via the camera - the thumbnail property fires - it doesn't find it in the cache and goes through the resizing routine.. but the resizing routine for some reason creates an empty byte[] from the stream its passed in and therefore the thumbnail never shows.

What I've seen is that when the image is added to the list, the property fires off, but the resizing routine only fires when the image comes into view - that is fine, but what happens is that when the user attempts to look at the thumbnail of the photo straight after creating it, the thumbnail is not created - so to me it sounds like the image hasn't finished creating itself (before it attempts to resize it). If you wait a few seconds before scrolling to the new item in the list, the thumbnail appears everytime. I can't figure out where I'm going wrong!

This is my property that I'm binding to in my listview with the resizing routine:

private ImageSource thumbnailImage;

        public ImageSource thumbnail
        {
          get
          {
            if (thumbnailImage == null)
            {
                // Get photo from filesystem
                thumbnailImage = ImageSource.FromStream(() => getImage(Image.details).Result);
              }
            }

            return thumbnailImage;
          }
        }

        private async Task<Stream> getImage(string imgFileName)
        {
          if (!thumbnailCache.ContainsKey(Image))
          {
            var imgFile = await FileSystem.Current.LocalStorage.GetFileAsync(imgFileName);
            byte[] fileContents;
            using (Stream x = await imgFile.OpenAsync(FileAccess.Read))
            {
              fileContents = DependencyService.Get<IMediaService>().ResizeImage(x, 100, 100);
            }
            thumbnailCache.Add(Image, fileContents);
            return new MemoryStream(fileContents);
          }
          else
            return new MemoryStream(thumbnailCache[Image]);
        }

MasterDetailPage or something else...

$
0
0

Hello, i'm new to Xamarin and i need some tips :) , i'm trying to figure it out how to start to develop XF for UWP.

The UI its very similar to a Masterdetailpage but i don't know if i can put buttons on the top and side bar. Can i do this with Grid?

What do you think is the best way forward?

How extend xamarin.forms theme?

$
0
0

I am using xamarin.forms light theme but I didnt like something about it. textcolor of the elements is white. it is a big conflict when theme is light and textcolor of label is white, you dont see the text. I want to extend it for some font and textcolor for each element. So how can I set for example all labels textcolor as black for entire app?

xamarin prism forms property changed not firing

$
0
0

I have a problem with prism.forms and propertychanged.

I have settingsmodel,settingsviewmodel and settingspage that shown code below,

SettingsModel

public class SettingsModel: BindableBase
{
    public string Url { get; set; }
    public bool IsEnabled{get;set;}
    public string ApiUrl { get; set; }


    public SettingsModel()
    {
        this.Url = string.Empty;
        this.IsEnabled = false;
        this.ApiUrl = string.Empty;
    }
}

SettingsViewModel

[ImplementPropertyChanged]
public class SettingsPageViewModel : ViewModelBase
{

    readonly INavigationService _navigationService;
    readonly IUserDialogs _userDialogs;
    readonly IProductService _productService;

    #region Constructor

    public SettingsPageViewModel(INavigationService navigationService,
                              IUserDialogs userDialogs, IProductService productService)
    {
        _navigationService = navigationService;
        _userDialogs = userDialogs;
        _productService = productService;

        this.Settings = new SettingsModel();

        SaveCommand = new DelegateCommand(Save).ObservesCanExecute((vm) => Settings.IsEnabled);

    }

    #endregion


    #region Model


    SettingsModel _settingsModel;
    public SettingsModel Settings
    {
        get { return _settingsModel; }
        set {

             if (_settingsModel != null)
                _settingsModel.PropertyChanged -= MyPersonOnPropertyChanged;

            SetProperty(ref _settingsModel, value);


             if (_settingsModel != null)
                _settingsModel.PropertyChanged += MyPersonOnPropertyChanged;

            Validation();
        }
    }


    public bool IsLoading { get; set; }

    public DelegateCommand SaveCommand { get; set; }
    #endregion


    void MyPersonOnPropertyChanged(object sender, PropertyChangedEventArgs propertyChangedEventArgs)
    {
        Validation();
    }

    #region Methods

    async void Save()
    {

        var result = await _productService.GetProducts(Priority.UserInitiated,"","","");

    }

    void Validation()
    {
        Settings.IsEnabled = !string.IsNullOrEmpty(Settings.ApiUrl) ? true : false;
    }




    #endregion
}

And SettingsPage XAML

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms"
    prism:ViewModelLocator.AutowireViewModel="True"
    x:Class="XXX.Warehouse.SettingsPage">

<Entry Text="{Binding Settings.ApiUrl}" Margin="0,5,0,5"
       Placeholder="www.example.com" HorizontalOptions="FillAndExpand" />
<Button Text="Save"
        FontSize="16"
        BorderRadius="5"
        TextColor="White"
        BackgroundColor ="#578A17"
        IsEnabled="{Binding Settings.IsEnabled}"
        Command="{Binding SaveCommand}" />

I want to do when user enter url than IsEnabled property will true, when Url is empty than IsEnabled property will false and save button if IsEnabled is false, button not enabled.

My main problem is, i write Entry url but propertychanged event not fired?

How can i solve this?

Thank you.


Xamarin forms StackLayout strange exception

$
0
0

Hello everyone, i found something strange in my application, in 1/30 (ios) and 1/1000 (android) i got strange exception in this 2 lines :

StackLayoutName.Children.Insert(StackLayoutName.Children.IndexOf(elementToRemove), temp); StackLayoutName.Children.Remove(elementToRemove);

I checked everything, no nulls in variables, no index out of range, no any mistake that i can't found, but i get exception.
Can anyone help me with it?

Сообщение: Object reference not set to an instance of an object Тип: System.NullReferenceException at Xamarin.Forms.BindableObject.GetContext (Xamarin.Forms.BindableProperty property) [0x00013] in C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Core\BindableObject.cs:489 at Xamarin.Forms.BindableObject.GetValue (Xamarin.Forms.BindableProperty property) [0x0000e] in C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Core\BindableObject.cs:54 at Xamarin.Forms.Layout.get_Padding () [0x00000] in C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Core\Layout.cs:84 at Xamarin.Forms.Layout.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00027] in C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Core\Layout.cs:111 at Xamarin.Forms.VisualElement.Measure (System.Double widthConstraint, System.Double heightConstraint, Xamarin.Forms.MeasureFlags flags) [0x00054] in C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Core\VisualElement.cs:527 at Xamarin.Forms.StackLayout.CalculateNaiveLayout (Xamarin.Forms.StackLayout+LayoutInformation layout, Xamarin.Forms.StackOrientation orientation, System.Double x, System.Double y, System.Double widthConstraint, System.Double heightConstraint) [0x00236] in C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Core\StackLayout.cs:185 at Xamarin.Forms.StackLayout.CalculateLayout (Xamarin.Forms.StackLayout+LayoutInformation layout, System.Double x, System.Double y, System.Double widthConstraint, System.Double heightConstraint, System.Boolean processExpanders) [0x00058] in C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Core\StackLayout.cs:110 at Xamarin.Forms.StackLayout.OnSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00019] in C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Core\StackLayout.cs:67 at Xamarin.Forms.VisualElement.OnMeasure (System.Double widthConstraint, System.Double heightConstraint) [0x00000] in C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Core\VisualElement.cs:593 at Xamarin.Forms.VisualElement.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00053] in C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Core\VisualElement.cs:469 at Xamarin.Forms.Layout.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00000] in C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Core\Layout.cs:110 at Xamarin.Forms.VisualElement.Measure (System.Double widthConstraint, System.Double heightConstraint, Xamarin.Forms.MeasureFlags flags) [0x00054] in C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Core\VisualElement.cs:527 at Xamarin.Forms.StackLayout.CalculateNaiveLayout (Xamarin.Forms.StackLayout+LayoutInformation layout, Xamarin.Forms.StackOrientation orientation, System.Double x, System.Double y, System.Double widthConstraint, System.Double heightConstraint) [0x000a8] in C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Core\StackLayout.cs:150 at Xamarin.Forms.StackLayout.CalculateLayout (Xamarin.Forms.StackLayout+LayoutInformation layout, System.Double x, System.Double y, System.Double widthConstraint, System.Double heightConstraint, System.Boolean processExpanders) [0x00058] in C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Core\StackLayout.cs:110 at Xamarin.Forms.StackLayout.OnSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00019] in C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Core\StackLayout.cs:67 at Xamarin.Forms.VisualElement.OnMeasure (System.Double widthConstraint, System.Double heightConstraint) [0x00000] in C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Core\VisualElement.cs:593 at Xamarin.Forms.VisualElement.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00053] in C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Core\VisualElement.cs:469 at Xamarin.Forms.Layout.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00000] in C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Core\Layout.cs:110 at Xamarin.Forms.VisualElement.Measure (System.Double widthConstraint, System.Double heightConstraint, Xamarin.Forms.MeasureFlags flags) [0x00054] in C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Core\VisualElement.cs:527 at Xamarin.Forms.StackLayout.CalculateNaiveLayout (Xamarin.Forms.StackLayout+LayoutInformation layout, Xamarin.Forms.StackOrientation orientation, System.Double x, System.Double y, System.Double widthConstraint, System.Double heightConstraint) [0x000a8] in C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Core\StackLayout.cs:150 at Xamarin.Forms.StackLayout.CalculateLayout (Xamarin.Forms.StackLayout+LayoutInformation layout, System.Double x, System.Double y, System.Double widthConstraint, System.Double heightConstraint, System.Boolean processExpanders) [0x00058] in C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Core\StackLayout.cs:110 at Xamarin.Forms.StackLayout.LayoutChildren (System.Double x, System.Double y, System.Double width, System.Double height) [0x0005b] in C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Core\StackLayout.cs:44 at Xamarin.Forms.Layout.UpdateChildrenLayout () [0x000c7] in C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Core\Layout.cs:229 at Xamarin.Forms.Layout.OnSizeAllocated (System.Double width, System.Double height) [0x0000f] in C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Core\Layout.cs:194 at Xamarin.Forms.VisualElement.SizeAllocated (System.Double width, System.Double height) [0x00000] in C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Core\VisualElement.cs:629 at Xamarin.Forms.Layout.ForceLayout () [0x00000] in C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Core\Layout.cs:104 at Xamarin.Forms.Layout.InvalidateLayout () [0x00016] in C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Core\Layout.cs:174 at Xamarin.Forms.Layout.OnInternalAdded (Xamarin.Forms.View view) [0x0002d] in C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Core\Layout.cs:404 at Xamarin.Forms.Layout.InternalChildrenOnCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00089] in C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Core\Layout.cs:392 at (wrapper delegate-invoke) <Module>:invoke_void_object_NotifyCollectionChangedEventArgs (object,System.Collections.Specialized.NotifyCollectionChangedEventArgs) at System.Collections.ObjectModel.ObservableCollection1[T].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00012] in /Users/builder/data/lanes/3818/ad1cd42d/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/referencesource/System/compmod/system/collections/objectmodel/observablecollection.cs:288
at System.Collections.ObjectModel.ObservableCollection1[T].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedAction action, System.Object item, System.Int32 index) [0x00000] in /Users/builder/data/lanes/3818/ad1cd42d/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/referencesource/System/compmod/system/collections/objectmodel/observablecollection.cs:351 at System.Collections.ObjectModel.ObservableCollection1[T].InsertItem (System.Int32 index, T item) [0x00024] in /Users/builder/data/lanes/3818/ad1cd42d/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/referencesource/System/compmod/system/collections/objectmodel/observablecollection.cs:219
at System.Collections.ObjectModel.Collection1[T].Insert (System.Int32 index, T item) [0x00038] in /Users/builder/data/lanes/3818/ad1cd42d/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/referencesource/mscorlib/system/collections/objectmodel/collection.cs:103 at Xamarin.Forms.ObservableWrapper2[TTrack,TRestrict].Insert (System.Int32 index, TRestrict item) [0x00032] in C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Core\ObservableWrapper.cs:117
at Application.UI.Menu.TestPage+d__11.MoveNext () [0x00640] in C:\Projects\Application.UI.Menu.TestPage.cs:303
`

Getting build errors when trying to implement localization

$
0
0

Hi,

I am trying to implement localization as descibed here: https://developer.xamarin.com/guides/xamarin-forms/advanced/localization/ for my xamarin forms project (Anroid, iOS, WindowsPhone).

For Windows Phone I had to add a class like this:

`
using System;
using Xamarin.Forms;
using System.Threading;
using System.Globalization;

[assembly: Dependency(typeof(OM_App.WinPhone.Localize))]

namespace MY_App.WinPhone
{
public class Localize : MY_App.ILocalize
{
public void SetLocale(CultureInfo ci) { }
public System.Globalization.CultureInfo GetCurrentCultureInfo()
{
return System.Threading.Thread.CurrentThread.CurrentUICulture;
}
}
}
`

I get a error on this line:

return System.Threading.Thread.CurrentThread.CurrentUICulture;

Fehler CS0234 Der Typ- oder Namespacename "Thread" ist im Namespace "System.Threading" nicht vorhanden. (Möglicherweise fehlt ein Assemblyverweis.)

which is german and roughly translates to:

Error CS0234 The Type- or Namespace-Name "Thread" is not available in the Namespace "System.Threading" (Maybe an Assemblyverweis is missing)

What is wrong?
Thanks!

ListView Recycling issue

$
0
0

Hoping to get some insight on this. I am trying to utilize Xamarin's ListView Recycling Cache strategy. Here is my XAML

<ListView x:Name="gridList" CachingStrategy="RecycleElement"> <ScrollView x:Name="listScroller"> <ListView.ItemTemplate> <DataTemplate> <ViewCell> <StackLayout> <Image Source="{Binding Image}"/> </StackLayout> </ViewCell> </DataTemplate> </ListView.ItemTemplate> </ScrollView> </ListView>

In my "code behind" (I say code behind because thats the term typically used in .NET) for this xaml page, I initialize the ItemsSource to a datatemplate using a custom cell that I made as such:

gridList.ItemTemplate = new DataTemplate(typeof(Classes.CustomGridCell));
gridList.ItemsSource = cells;
Content = gridList;

Here is my CustomGridCell implementation:

   Xamarin.Forms.Image cellImage;
    public CustomGridCell()
    {
        cellImage = new Xamarin.Forms.Image();
        View = cellImage;
    }

    protected override void OnBindingContextChanged()
    {
        base.OnBindingContextChanged();
        var item = BindingContext as XamarinMobile.ViewModels.GridCellViewModel;

        if (item == null)
            return;

        cellImage.Source = Xamarin.Forms.ImageSource.FromUri(new System.Uri(item.Image));

    }

And when I receive data, I iterate through my list of objects and add cells as such:

var stories = gridViewModel.GridList; foreach (MobileObjects.GridListStory story in stories.StoryList) { cells.Add(new ViewModels.GridCellViewModel { Image = story.SquareImageURL }); }

What seems to be happening is, the first iteration of my collection of stories.StoryList hits the cells.Add line. In turn, I see my CustomGridCell OnBindingContextChanged method being hit. The problem is, it hits the first time and then never gets hit again. After putting a breakpoint on my cells.Add... code, I can see that this never gets called again. As if there's some type of exception which is never fired. Checking the ouput, I do not see any kind of errors. But the foreach is essentially being thrown out after the first iteration and I don't even see that image.

When I change my CachingStrategy to RetainElement everything works fine and the iterations happen as they should. Hoping someone sees an immediate problem with what I am doing. I took most of this from Xamarin website itself, but it's possible I missed something.

Xamarin Forms Entry throwing Java.Lang.ArrayIndexOutOfBoundsException

Iam getting image source from Camera plugin, then how can i convert image file path to base64 ?

$
0
0

Iam getting image source from Camera plugin, then how can i convert image file path to base64 for saving in DB.
getting path like this /storage/emulated/0/Android/data/AvanteGardeCamera.Droid/files/Pictures/Sample/test_29.jpg.

Viewing all 58056 articles
Browse latest View live