Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all 204402 articles
Browse latest View live

DependencyService ist't work (SQLite, PCL)

$
0
0

Hello. I try to use SQLite. I try to do https://developer.xamarin.com/guides/xamarin-forms/application-fundamentals/databases/ for that.
But I get error for iOS:

The type or namespace name 'IFileHelper' could not be found (are you missing a using directive or an assembly reference?)

and Android:
The "ResolveLibraryProjectImports" task failed unexpectedly.
System.IO.PathTooLongException: The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
at System.IO.PathHelper.GetFullPathName()
at System.IO.Path.LegacyNormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
at System.IO.Path.GetFullPathInternal(String path)
at Xamarin.Android.Tools.Files.ExtractAll(ZipArchive zip, String destination, Action2 progressCallback, Func2 modifyCallback, Func2 deleteCallback, Boolean forceUpdate) at Xamarin.Android.Tasks.ResolveLibraryProjectImports.Extract(DirectoryAssemblyResolver res, ICollection1 jars, ICollection1 resolvedResourceDirectories, ICollection1 resolvedAssetDirectories, ICollection`1 resolvedEnvironments)
at Xamarin.Android.Tasks.ResolveLibraryProjectImports.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext()

What could be the problem?


The Switch animation is not smooth when i display a button

$
0
0

Hello,

I have a listview which contains items, foreach items i have a switch.
Each switch "IsToggled" is binded to my item property (Slot.IsSelected).
Each switch call the same "PRISM" command (RefreshHasOneSlotSelectedCommand).
My command change my viewmodel boolean property "HasOneSlotSelected" to true or false.
This property is simply binded to a "IsVisible" button property.

My switch animation is not smooth ONLY if this button is display or hide, for example:

  • I have 1 item with a toggled switch, if i toggled/untoggled others items then i don't have UI lags
  • I have 1 item with a toggled switch, if i untoggled him then i have UI lags
  • I have 0 item with a toggled switch, if i toggled one then i have UI lags

So i deduce that is the display/hide of my button which create UI lags, any idea?

Edit: when i comment the button xaml, i don't have UI lags!

Xaml:

                                <Switch IsToggled="{Binding IsSelected}"
                                        VerticalOptions="Center"
                                        HorizontalOptions="End">
                                    <Switch.Behaviors>
                                        <behaviors:EventToCommandBehavior Command="{Binding Source={x:Reference ThisPage}, Path=BindingContext.RefreshHasOneSlotSelectedCommand}"
                                                                          EventName="Toggled"/>
                                    </Switch.Behaviors>
                                </Switch>


        <Button Text="{markupExtensions:Translate NextStep}"
                IsVisible="{Binding HasOneSlotSelected}"
                Command="{Binding NextStepCommand}"/>

Command:

        private DelegateCommand _refreshHasOneSlotSelectedCommand;
        public DelegateCommand RefreshHasOneSlotSelectedCommand => _refreshHasOneSlotSelectedCommand ?? (_refreshHasOneSlotSelectedCommand =
            new DelegateCommand(RefreshHasOneSlotSelected, () => IsInitialized))
            .ObservesProperty(() => IsInitialized);

Method command:

        private void RefreshHasOneSlotSelected()
        {
            HasOneSlotSelected = Need.Slots.Where(slot => slot.IsSelected).Count() > 0;
        }

Best regards

How to resize photo and specify nested folders using Media Plugin?

$
0
0

Can anyone spot why the following code isn't resizing my photos:

if (CrossMedia.Current.IsCameraAvailable && CrossMedia.Current.IsTakePhotoSupported)
{
var mediaOptions = new Plugin.Media.Abstractions.StoreCameraMediaOptions
{
PhotoSize = PhotoSize.MaxWidthHeight,
MaxWidthHeight = 100,
RotateImage = true,
Directory = "Items/",
Name = _item.Id + ".jpg",
SaveToAlbum = true,
CompressionQuality = 75
};

var file = await CrossMedia.Current.TakePhotoAsync(mediaOptions);

}

I've tried various permutations of the above, but nothing seems to work.

Also, what is the correct way to set the Directory string when you need to specify sub folders? E.g. I need to save into Today/Items/, but when I set Directory to "Today/Items/" the media plugin simply creates a folder called "TodayItems".

Xamarin.Forms Previewer not working in 17.4.4 as well as 17.5.5

$
0
0

Hi Community,

I am facing problems while using Xamarin.Forms Previewer. It has worked only for the initial templated MainPage.xaml skeleton page. [VS 2017 15.4.4]
After creating the skeleton project, I tried to add bunch of content pages inside a subfolder within the PCL project.
Ever since then, I have been getting all kinds of errors while using the previewer. One of the screenshot is attached below.

Another set of errors include, connection timeout; please rebuild android project...
It is annoying to focus on such issues rather than learn this technology to solve business problems...

I tried to upload the screenshot with other errors and got a warning in a red banner - "You have to be around for a little while longer before you can post links." .... what is this?

Your help will be appreciated.

Thanks,
XamIT

Can't run Xamarin project after installing SkiaSharp?

$
0
0

I installed SkiaSharp and SkiaSharp.Views.Forms
and when I used them in my code:

public MainPage()
        {
            InitializeComponent();

            SKCanvasView canvasView = new SKCanvasView();
            canvasView.PaintSurface += OnCanvasViewPaintSurface;
            Content = canvasView;

        }

The project can't run, (the orange color of the debugging mode just disappear immediately), and there're no errors.

when I commented out the code above, the project run normally!
I'm using Visual Studio 2017 15.4.5
Any help?

How trigger the DateSelected event of DatePicker only if the user tap on "Done" on iOS?

$
0
0

Hello,

How trigger the DateSelected event of DatePicker only if the user tap on "Done" on iOS?

Currently the event is triggered if you change the year, month or date

Best regards.

Binding Objective C Lib

$
0
0

I developed an application which wants to bind with Objective c lib (.a file). This application has lots of packages which supports Target framework Xamarin Mac Full. But when I created the binding project it is created as Xamarin Mac Modern. When I changed it to Xamarin Mac Full it shows lots of error, Xamarin.Mac reference is also missing. Please help me on this. How to solve this issue. I am new in Xamarin, so please excuse if anything wrong.

Icon image on Toolbar item in xamarin Forms

$
0
0

Hi,
I'm creating all forms UI with the code using the Shared project. I want to add the icon image to the toolbar item. Can anyone guide me how can I achieve the same ? I could not find a suitable example in the docs section of Working with images. They mostly deal with the Local and Embedded Images. The sample code should work for all the platforms.

Thanks


Using Xamarin.Auth with Xamarin.Forms

$
0
0

How you can use Xamarin.Auth when you're using Xamarin.Forms?

I have this:

async public System.Threading.Tasks.Task<bool> LoginWithFacebook (object dialog, string FacebookAppID)
        {
            var user = new ParseUser ();
            var auth = new OAuth2Authenticator (
                           clientId: FacebookAppID,
                           scope: "",
                           authorizeUrl: new Uri ("https://m.facebook.com/dialog/oauth/"),
                           redirectUrl: new Uri ("http://www.facebook.com/connect/login_success.html"));
            auth.AllowCancel = true;
            // If authorization succeeds or is canceled, .Completed will be fired.
            auth.Completed += async (object sender, AuthenticatorCompletedEventArgs ee) => {

                // Now that we're logged in, make a OAuth2 request to get the user's info.
                var accessToken = ee.Account.Properties ["access_token"].ToString ();
                var expiresIn = Convert.ToDouble (ee.Account.Properties ["expires_in"]);
                var expiryDate = DateTime.Now + TimeSpan.FromSeconds (expiresIn);

                // Now that we're logged in, make a OAuth2 request to get the user's id.
                var request = new OAuth2Request ("GET", new Uri ("https://graph.facebook.com/me"), null, ee.Account);
                var response = await request.GetResponseAsync ();
                var obj = JObject.Parse (response.GetResponseText ());
                var id = obj ["id"].ToString ().Replace ("\"", ""); // Id has extraneous quotation marks
                user = await ParseFacebookUtils.LogInAsync (id, accessToken, expiryDate);

            };
            var dvc = ((DialogViewController)dialog);
            dvc.PresentViewController (auth.GetUI (), true, null);
            return user.IsAuthenticated;
        }

But I can't cast ContentPage to DialogViewController or an Activity

Issue with QLPreviewController

$
0
0

Hi,

I am trying to use QLPreviewController to see a PDF file and send it, but I have an issue with the action button after previewing the PDF document.

When I press the action button (at the top right) app crashes and I get:
"Unhandled managed exception: Objective-C exception thrown. Name: NSInternalInconsistencyException Reason: UIDocumentInteractionController: invalid scheme (null). Only the file scheme is supported. (MonoTouch.Foundation.MonoTouchException)"

I did some research and it seams that this issue may occur if you download a file from the internet or if the file type is not "file:// .......... ".
My NSUrl is on that format so I dont know why I have this error.

Anybody has any idea?

Thanks

Here is my code to call the Controller:

 QLPreviewController previewController= new QLPreviewController();
 previewController.DataSource=new MyQLPreviewControllerDataSource();
 this.PresentViewController(previewController,true, null);

This is my code for the DataSource:

public class MyQLPreviewControllerDataSource : QLPreviewControllerDataSource
{
    public override int PreviewItemCount (QLPreviewController controller)
    {

        return 1;
    }

    public override QLPreviewItem GetPreviewItem (QLPreviewController controller, int index)
    {

        string fileName = @"example.pdf";
        var documents = Environment.GetFolderPath (Environment.SpecialFolder.MyDocuments);
        var library = Path.Combine (documents,fileName);
        NSUrl url = NSUrl.FromFilename (library);
        return new QlItem ("Title", url);
    }
}

This is my code for the item:

public class QlItem : QLPreviewItem
{
    string _title;
    Uri _uri;

    public QlItem (string title, Uri uri)
    {
        this._title = title;
        this._uri = uri;
    }

    public override string ItemTitle {
        get { return _title; }
    }

    public override NSUrl ItemUrl {
        get { return _uri; }
    }
}

Is it discouraged to bind between the view and the page class without a VW class?

$
0
0

The guide to Xamarin and examples there show how to bind between datasource and views. However, it seems that the 'standard' way is to create a intermediary class (i.e a VW class) to link/isolate the data and the UI controls. But since each xaml file has a code-behind file automatically generated and the class is automatically generated too, why it won't work if the binding property is directly put as a part of the page class?

For example, I generated an app1 view and the corresponding mainpage automatically

<ContentPage.Content>
    <StackLayout  x:Name="layoutNo2">
        <Label x:Name="changelabel"
            Text="{Binding textcontent}"
               TextColor="#f35e20"/>
        <Button Text="testbutton"
                Clicked="Ontestbutton"/>
        </StackLayout>
</ContentPage.Content>

And the code behind file

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;

namespace App1
{
public partial class MainPage : ContentPage
{
private string textcontent = "";
public MainPage()
{
InitializeComponent();
}

    private void Ontestbutton(object sender, EventArgs e)
    {
        textcontent = "sjflajs";
    }
}

}

But the binding is never working, even if I put

    changelabel.BindingContext = textcontent;
        changelabel.SetBinding(Label.TextProperty, "PATH=textcontent");

after InitializeComponent(); in the constructor.

So, a VW class is a must-to-have for data binding?

Migrating to GitHub Issues and Projects

$
0
0

GitHub Issues

We're excited to announce GitHub Issues is now open on our repository. This is our new home for reporting bugs as well as discussing enhancement requests.

What does this mean?

  • Bugzilla will remain open for the time being, and existing issues will continue to be worked there
  • All new issues should be filed on GitHub
  • The Evolution forum is being deprecated. Existing proposals will remain. New proposals and requests should be moved to GitHub Issues

GitHub Projects

GitHub Projects has also recently been made available to us and we are discussing how we will use it for tracking issues, features, and other work. Watch that space for an even higher level of visibility into everything going on with Xamarin.Forms.

What is AndroidUseSharedRuntime default value?

$
0
0

I have a clean Xamarin Android app (VS for Mac) with Debug and Release configurations, and in project options editor "Use Shared Mono Runtime" option is enabled for Debug configuration

But inside my csproj file I have no <AndroidUseSharedRuntime>true</AndroidUseSharedRuntime> for Debug configuration - does that mean that by default AndroidUseSharedRuntime is always true?

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="<link removed>">
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProjectGuid>{D39E3CBC-67CB-46D8-ADD1-5C138CA66DE6}</ProjectGuid>
    <ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
    <OutputType>Library</OutputType>
    <RootNamespace>androidxamarinapplication</RootNamespace>
    <AssemblyName>android-xamarin-application</AssemblyName>
    <TargetFrameworkVersion>v8.0</TargetFrameworkVersion>
    <AndroidApplication>True</AndroidApplication>
    <AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile>
    <AndroidResgenClass>Resource</AndroidResgenClass>
    <AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
    <MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
    <MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
    <AndroidUseLatestPlatformSdk>true</AndroidUseLatestPlatformSdk>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug</OutputPath>
    <DefineConstants>DEBUG;</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <AndroidLinkMode>None</AndroidLinkMode>
    <EmbedAssembliesIntoApk>false</EmbedAssembliesIntoApk>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release</OutputPath>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <AndroidManagedSymbols>true</AndroidManagedSymbols>
    <AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
  </PropertyGroup>
  ...

Automatic expandable editor

$
0
0

Basically I want an input field, which expands whenever the user puts too much text in it. There are several approaches out there trying to achieve this. The problem exists in web developement too and it's pretty basic (as seen by an user).

I went with the most logical (well, for me) approach I found. Extend the Changed-event.

private void OnTextChanged_Grow(object inSender, TextChangedEventArgs inEventArgs)
{
      InvalidateMeasure();
}

But this heavily affects the performance! The power needed to invalidate the view each time the user presses a key is just too much.

Is there any other clean way to do it? Maybe even a change to the design / architecture?

Thanks in advance.

After update VS 15.5 can't load MonoAndroidDesignerPackage, any workaround ?

$
0
0

Hello,
after update VS with 15.5 when open VS i catch this error "Can't load MonoAndroidDesignerPackage",
how can resolve this problem ?


How to Localize IKImageEditPanel.SharedPanel

$
0
0

This ImageKit image editing panel is great, but does anybody know how to localize it. Or is there a way to specify the locale to it such that it localizes itself?

Thanks

Upgrading to Xamarin Forms 2.5 - Android

$
0
0

When I try to upgrade Xamarin Forms to 2.5 on Android (from 2.4), I get a package error that says it can't find a compatible package Xamarin.GooglePlayServices.Maps. I am currently running version 29.0.0.2 and it is requesting 42.1021.1.

I get really confused on build version between Android API level, Xamarin Support Package build, and Play Services build version (for instance Google Play Services has version 11.6.0, but the nuget package is 42).

So I think I need to upgrade my GooglePlayServices nuget package to 42; however, I think that targets Android O which also means I need to transition some of my code over as well (foreground service calls are a little different, etc.).

What I'm confused about is how does this relate to the user experience? Does the user need to upgrade their PlayServices as well? If so, how is that typically handled? I'd like to use the connectionless client for Geofencing which is part of the latest play services packages. Does that mean the user can't use this feature until PlayServices are upgraded?

Sorry for the long post, but Android confuses me.

which ports are needed for Live Player?

$
0
0

I've been able to get Live Player to work with the Color Control demo program on two phones inside my network by opening up port 8090 tcp outbound. It connects to 52.225.130.190:8090 which is obviously outside my internal 172.16.0.x network.

  1. Are any other ports needed?

  2. Would it be possible to have VS 2017 look for a phone Outside my network? I'd love to be able to have a client run a quick test on his phone!!! I haven't been able to get that to work. As VS 2017 is talking to an ip outside on the internet during normal use of Live Player (even when VS 2017 and the iPhone are both on an internal network), hopefully this is possible?

  3. Is there a way to remove the name of the iPhone's setup from the VS 2017 Live Player devices? I've changed my test phone names to match the color of their cases to make them easier to identify.

How Can I Debug a Release Build In Visual Studio

$
0
0

I am trying to get "in app billing" working in my Android app. The only way you can test "in app billing" with your real products is to use a real device, Release mode and signed APK. I have tried "Enable Debugging" in Release mode, but no luck. The app starts but the debugger does not attach. And it does not seem like you can attach an already running process. Any ideas how to get this to work?

Mac App rejected due to MapKit not being linked

$
0
0

My app was rejected from the Mac App Store for the following reason:
2.3 - Apps that do not perform as advertised by the developer will be rejected

The app still has the MapKit entitlement without linking against the MapKit framework.

My application targets the 64 bit architecture, links to the Native MapKit, associates the CFBundleIdentifier in Info.plist to the one created with Apple with Maps permissions. I am using the latest Stable releases of Xamarin.

Any thoughts on why this would happen?

Viewing all 204402 articles
Browse latest View live


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