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

Displaying a PDF doesn't work for iOS

$
0
0

I was following this tutorial for displaying a PDF in both platforms and Android works, but iOS doesn't. It functions like Android where the user will press a button to display the PDF and just like Android it opens up a new page like it is supposed to. However, nothing shows after the button is pressed and the new page is shown. It is just a blank page and nothing happens after that. I tried to substitute the iOS version with Device.OpenURI but I'm not a fan of the two platforms being vastly different. Anyone have any ideas why the tutorial code isn't working correctly?


Share Text to my Xamarin forms ios app

$
0
0

Hi,

Could any one help me to explain how i can share text from notes, browser, ... etc to my app in ios
something like this

Thanks

Change platform specific property of a cross platform element

$
0
0

Hi everyone,

I have a project in which I am using a Slider. Problem is that the slider in UWP displays a tooltip that show the value as you change it. I don't want that, but I can't find a way to disable the corresponding property as it is a Windows.UI.Xaml.Controls.Slider property, and not a Xamarin.Forms.Slider property. I feel it should be basic but I must have missed something.

Thanks in advance !

Xamarin.Forms + Visual Studio 2017 15.8.1

$
0
0

Hi all together,
after updating VS to 15.8.1 i have big problems with VS. I have to cancel every other build and run 'Clean Solution' otherwise VS hangs.
After running Clean i can make one or two build then i have the same Problem.
Any idea??.
Thanks in advance
Peter

PopAsync from a contentPage to ContentView doesnt work

$
0
0

Hi all,

I'm navigating from a ContentView to a ContentPage with pushAsync method. However, If I want to go back with PopAsync, it doesn't work. Does anyone know how to fix this ? Please help me out.

Is it possible to build abstract subclass of ContentPage?

$
0
0

I am trying to add some functionality to the core pages of my application by writing an abstract ContentPage subclass that is then inherited by all of my app pages.

Whenever I try to use any of the abstract classes methods however, I am getting a System.AggregateException thrown in an unrelated method that handles server requests. I have also tried placing the methods in an interface instead, but it still throws the same exception.

Am I missing something obvious here, or does anyone have any ideas?

Thanks

How to make Color.Accent match your Android app's theme

$
0
0

As you may be aware, Xamarin.Forms' Color.Accent is a static, internally set property for use throughout your Xamarin.Forms app. Unfortunately, Color.Accent does not care about the accent color you set in your app's Material Design theme. If you would like Color.Accent to match your theme, this is a code snippet I developed, using reflection to access the internal setter. You want to place it in your MainActivity's OnCreate() method, after Xamarin.Forms.Forms.Init() has been called, as that is where Color.Accent is originally set to Holo Blue. Enjoy.

protected override void OnCreate(Bundle bundle)
{
    global::Xamarin.Forms.Forms.Init(this, bundle)

    // get the accent color from your theme
    var themeAccentColor = new TypedValue();
    this.Theme.ResolveAttribute(Resource.Attribute.colorAccent, themeAccentColor, true);
    var droidAccentColor = new Android.Graphics.Color(themeAccentColor.Data);

    // set Xamarin Color.Accent to match the theme's accent color
    var accentColorProp = typeof(Xamarin.Forms.Color).GetProperty(nameof(Xamarin.Forms.Color.Accent), System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static);
    var xamarinAccentColor = new Xamarin.Forms.Color(droidAccentColor.R / 255.0, droidAccentColor.G / 255.0, droidAccentColor.B / 255.0, droidAccentColor.A / 255.0);
    accentColorProp.SetValue(null, xamarinAccentColor, System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static, null, null, System.Globalization.CultureInfo.CurrentCulture);

    LoadApplication(new App());
}

Trigger a Picker wihtin a DataTemplate

$
0
0

Hi,

I have a ListView with a DataTemplate, within the DataTemplate is a Picker for every entry.
I want the picker to open his dialog when you select an entry.

Executing "Picker.Focus()" does not work for me.

selectionLv.ItemSelected += (sender, args) =>{ var item = args.SelectedItem; var listView = sender as ListView; var itemTemplate = list.TemplatedItems.FirstOrDefault(tpl => tpl.BindingContext is objectX x && x.Equals(item)); var picker = itemTemplate.FindByName<Picker>("Picker1"); if (picker .IsFocused) picker .Unfocus(); picker .Focus(); };

any solutions ?


How to give Permission for Camera used in iOS App with Xamarin forms.

$
0
0

Hi , I need to used Camera and Photos in my App . I am using Xamarin forms.
Camera and Photos Library Access working fine in Android App . But not in iOS App.
is There anyone know , how can i used Camera and Photos for iOS App?

Thanks !!

I have a small image (24px * 24px) that I want to repeat for the background image. Is there

$
0
0

I have a small image (24px * 24px) that I want to repeat for the background image. Is there a way to do this?

Error when targetting UWP (Windows 10 Creators Update - 10.0; Build 15063)

$
0
0

Hi,

I'm trying to set the UWP project of a Xamarin Forms solution to the following:

Target Version: (Windows 10 Creators Update - 10.0; Build 15063)
Min Version: (Windows 10 November Update - 10.0; Build 10586)

But when I try to compile the project, I get the following errors:

Error Project '..\MyApp\MyApp.csproj' targets 'netstandard2.0'. It cannot be referenced by a project that targets 'UAP,Version=v10.0.10586'. MyApp.UWP

Error NU1201 Project MyApp is not compatible with uap10.0.10586 (UAP,Version=v10.0.10586) / win10-x86-aot. Project MyApp supports: netstandard2.0 (.NETStandard,Version=v2.0) MyApp.UWP D:\Projects\MyApp\MyApp\MyApp.UWP\MyApp.UWP.csproj 1

Error NU1201 Project MyApp is not compatible with uap10.0.10586 (UAP,Version=v10.0.10586) / win10-x64. Project MyApp supports: netstandard2.0 (.NETStandard,Version=v2.0) MyApp.UWP D:\Projects\MyApp\MyApp\MyApp.UWP\MyApp.UWP.csproj 1

Error NU1201 Project MyApp is not compatible with uap10.0.10586 (UAP,Version=v10.0.10586) / win10-arm64-aot. Project MyApp supports: netstandard2.0 (.NETStandard,Version=v2.0) MyApp.UWP D:\Projects\MyApp\MyApp\MyApp.UWP\MyApp.UWP.csproj 1

Error NU1201 Project MyApp is not compatible with uap10.0.10586 (UAP,Version=v10.0.10586) / win10-x64-aot. Project MyApp supports: netstandard2.0 (.NETStandard,Version=v2.0) MyApp.UWP D:\Projects\MyApp\MyApp\MyApp.UWP\MyApp.UWP.csproj 1

Error NU1201 Project MyApp is not compatible with uap10.0.10586 (UAP,Version=v10.0.10586). Project MyApp supports: netstandard2.0 (.NETStandard,Version=v2.0) MyApp.UWP D:\Projects\MyApp\MyApp\MyApp.UWP\MyApp.UWP.csproj 1

Error NU1201 Project MyApp is not compatible with uap10.0.10586 (UAP,Version=v10.0.10586) / win10-x86. Project MyApp supports: netstandard2.0 (.NETStandard,Version=v2.0) MyApp.UWP D:\Projects\MyApp\MyApp\MyApp.UWP\MyApp.UWP.csproj 1

Error NU1201 Project MyApp is not compatible with uap10.0.10586 (UAP,Version=v10.0.10586) / win10-arm-aot. Project MyApp supports: netstandard2.0 (.NETStandard,Version=v2.0) MyApp.UWP D:\Projects\MyApp\MyApp\MyApp.UWP\MyApp.UWP.csproj 1

Error NU1201 Project MyApp is not compatible with uap10.0.10586 (UAP,Version=v10.0.10586) / win10-arm. Project MyApp supports: netstandard2.0 (.NETStandard,Version=v2.0) MyApp.UWP D:\Projects\MyApp\MyApp\MyApp.UWP\MyApp.UWP.csproj 1

I assume it is related to the fact that the project is still referencing .NET Standards 2.0 and it is clearly not compatible with the UWP Min and Target version being used but I'm not sure how to resolve it?

Can anyone help?

Thanks.

Taking photo with Custom Renderer Camera Preview

Job Scheduler problem

$
0
0

Hi,

I would like to implement Job Scheduler which is a great substitution for a classical background service. I tried to test the simple scenario where the Job Scheduler is started when the application goes to background or is closed. The Job Scheduler is canceled at the moment when the application starts opening or resuming. For this purpose, I wrote the following code in App class

protected override void OnStart()
{
var message = new StopLongRunningTaskMessage();
MessagingCenter.Send(message, "StopLongRunningTaskMessage");
}

    protected override void OnSleep()
    {
        var message = new StartLongRunningTaskMessage();
        MessagingCenter.Send(message, "StartLongRunningTaskMessage");
    }

    protected override void OnResume()
    {
        var message = new StopLongRunningTaskMessage();
        MessagingCenter.Send(message, "StopLongRunningTaskMessage");
    }

The method OnCreate in MainActivity class has the following code:

MessagingCenter.Subscribe(this, "StartLongRunningTaskMessage", message =>
{

                if (!IsJobServiceOn())
                {
                    _jobScheduler = (JobScheduler)GetSystemService(JobSchedulerService);
                    var extra = new PersistableBundle();
                    extra.PutInt("LoopCount", 20);
                    var javaClass = Java.Lang.Class.FromType(typeof(MyFirstservice));
                    var compName = new ComponentName(this, javaClass);
                    var jobInfo = new JobInfo.Builder(1, compName)
                                              .SetPersisted(true)
                                              .SetExtras(extra)
                                              .SetPeriodic(900000)
                                              .Build();

                    var result = _jobScheduler.Schedule(jobInfo);                     
                }         

        });

        MessagingCenter.Subscribe<StopLongRunningTaskMessage>(this, "StopLongRunningTaskMessage", message => {
            if (IsJobServiceOn())
                _jobScheduler.Cancel(1);
        });
    }


    private bool IsJobServiceOn()
    {
        JobScheduler scheduler = (JobScheduler)GetSystemService(JobSchedulerService);

        if (scheduler.GetPendingJob(1) != null)
            return true;
        else
            return false;
    }

The JobScheduler works fine as long as the application is not swiped out or closed entirely. I really do not know why the application crashes when it is restarted after it was swiped out from the recent app list.

Thanks for help in advance.
Samo

Displaying a PDF doesn't work for iOS

$
0
0

I was following this tutorial for displaying a PDF in both platforms and Android works, but iOS doesn't. It functions like Android where the user will press a button to display the PDF and just like Android it opens up a new page like it is supposed to. However, nothing shows after the button is pressed and the new page is shown. It is just a blank page and nothing happens after that. I tried to substitute the iOS version with Device.OpenURI but I'm not a fan of the two platforms being vastly different. Anyone have any ideas why the tutorial code isn't working correctly?

Job Scheduler problem

$
0
0

Hi,

I would like to implement Job Scheduler which is a great substitution for a classical background service. I tried to test the simple scenario where the Job Scheduler is started when the application goes to background or is closed. The Job Scheduler is canceled at the moment when the application starts opening or resuming. For this purpose, I wrote the following code in App class

protected override void OnStart()
{
var message = new StopLongRunningTaskMessage();
MessagingCenter.Send(message, "StopLongRunningTaskMessage");
}

    protected override void OnSleep()
    {
        var message = new StartLongRunningTaskMessage();
        MessagingCenter.Send(message, "StartLongRunningTaskMessage");
    }

    protected override void OnResume()
    {
        var message = new StopLongRunningTaskMessage();
        MessagingCenter.Send(message, "StopLongRunningTaskMessage");
    }

The method OnCreate in MainActivity class has the following code:

MessagingCenter.Subscribe(this, "StartLongRunningTaskMessage", message =>
{

                if (!IsJobServiceOn())
                {
                    _jobScheduler = (JobScheduler)GetSystemService(JobSchedulerService);
                    var extra = new PersistableBundle();
                    extra.PutInt("LoopCount", 20);
                    var javaClass = Java.Lang.Class.FromType(typeof(MyFirstservice));
                    var compName = new ComponentName(this, javaClass);
                    var jobInfo = new JobInfo.Builder(1, compName)
                                              .SetPersisted(true)
                                              .SetExtras(extra)
                                              .SetPeriodic(900000)
                                              .Build();

                    var result = _jobScheduler.Schedule(jobInfo);                     
                }         

        });

        MessagingCenter.Subscribe<StopLongRunningTaskMessage>(this, "StopLongRunningTaskMessage", message => {
            if (IsJobServiceOn())
                _jobScheduler.Cancel(1);
        });
    }


    private bool IsJobServiceOn()
    {
        JobScheduler scheduler = (JobScheduler)GetSystemService(JobSchedulerService);

        if (scheduler.GetPendingJob(1) != null)
            return true;
        else
            return false;
    }

The JobScheduler works fine as long as the application is not swiped out or closed entirely. I really do not know why the application crashes when it is restarted after it was swiped out from the recent app list.

Thanks for help in advance.
Samo


Getting Parent name for binding source in ConventView used as control/snippet in many pages...

$
0
0

In an attempt to abstract out XMAL code that repeats on many pages, I have been creating ContentView control parts to add into pages. I am having an issue with the below code that I extracted out of a page that is exactly the same in 8 other pages. In the parent page the below page is rendered with:

         <common:StackLayout_SearchResultsListview_Default Grid.Row="2" ></common:StackLayout_SearchResultsListview_Default>

However my resolving of method for the behavior is failing. When it was inline the below would have the name of the Page/Model for the X:Reference but now that it is used in many pages, I need it's Parent's (the Pages) name [hence the 'NeedParentName]. Is there an easy why get/describe the Page's Name that it is put in? As an example if placed in the EventShopInPage which has it's ContentPage attribute of x:Name="EventShopInPage" is there some magic word I can substitute in that resolved to the x:Name attribute of it's Parent ContentPage?

      <local:InvokeMethodAction TargetObject="{Binding Source= {x:Reference **NeedParentName** }, Path=BindingContext }" 
                                                            MethodName="Selected_Toggled" />

<?xml version="1.0" encoding="utf-8" ?>
<ContentView xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="MICX.Pages.Common.StackLayout_SearchResultsListview_Default"
             xmlns:local="clr-namespace:MICX.Controls"  
            >
    <ContentView.Content>

        <!--List View of results -->
        <StackLayout  Grid.Row="2" HorizontalOptions="Fill" VerticalOptions="EndAndExpand" Padding="5">
            <ListView  ItemsSource="{Binding BomAssemList}" >
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <ViewCell>
                            <StackLayout Orientation="Horizontal">
                                <Switch WidthRequest="90" IsToggled="{Binding Selected}" >
                                    <Switch.Behaviors>
                                        <local:EventHandlerBehavior EventName="Toggled">
                                            <local:InvokeMethodAction TargetObject="{Binding Source= {x:Reference NeedParentName }, Path=BindingContext }" 
                                                            MethodName="Selected_Toggled" />
                                        </local:EventHandlerBehavior>
                                    </Switch.Behaviors>
                                </Switch>
                                <Label WidthRequest="70"  Text="{Binding BomAssemShipMark}"></Label>
                                <Label WidthRequest="50" Text="{Binding TierSecDisp}"></Label>
                                <Label  WidthRequest="30" Text="{Binding BomAssemRev}"></Label>
                                <Label  WidthRequest="180" Text="{Binding BomAssemStatusDesc}"></Label>
                                <Label WidthRequest="45" Text="{Binding CurrentLocation}"></Label>
                                <Label  WidthRequest="90" Text="{Binding HeatNumber}"></Label>
                            </StackLayout>
                        </ViewCell>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>
        </StackLayout>

    </ContentView.Content>
</ContentView>

Xamarin Forms deployment not deploying updated assemblies (not using Fast Deploy/Shared Runtime)

$
0
0

Anyone had issues with builds/deployment not grabbing the latest supporting assemblies? My team has been facing many issues with this occurring.

Example: We have a project for Configurations where we have a static class that holds a bunch of configs used throughout the app. We can add a property to it build, deploy and attempt to go to a portion of the app that uses that newly added property and the app blows up because the assembly deployed was not up to date (hence not containing that property).

It happens all over the app with different projects. We are not using Fast Deploy/etc. and it is still happening. Any thoughts?

Job Scheduler problem

$
0
0

Hi,

I would like to implement Job Scheduler which is a great substitution for a classical background service. I tried to test the simple scenario where the Job Scheduler is started when the application goes to background or is closed. The Job Scheduler is canceled at the moment when the application starts opening or resuming. For this purpose, I wrote the following code in App class

protected override void OnStart()
{
var message = new StopLongRunningTaskMessage();
MessagingCenter.Send(message, "StopLongRunningTaskMessage");
}

    protected override void OnSleep()
    {
        var message = new StartLongRunningTaskMessage();
        MessagingCenter.Send(message, "StartLongRunningTaskMessage");
    }

    protected override void OnResume()
    {
        var message = new StopLongRunningTaskMessage();
        MessagingCenter.Send(message, "StopLongRunningTaskMessage");
    }

The method OnCreate in MainActivity class has the following code:

MessagingCenter.Subscribe(this, "StartLongRunningTaskMessage", message =>
{

                if (!IsJobServiceOn())
                {
                    _jobScheduler = (JobScheduler)GetSystemService(JobSchedulerService);
                    var extra = new PersistableBundle();
                    extra.PutInt("LoopCount", 20);
                    var javaClass = Java.Lang.Class.FromType(typeof(MyFirstservice));
                    var compName = new ComponentName(this, javaClass);
                    var jobInfo = new JobInfo.Builder(1, compName)
                                              .SetPersisted(true)
                                              .SetExtras(extra)
                                              .SetPeriodic(900000)
                                              .Build();

                    var result = _jobScheduler.Schedule(jobInfo);                     
                }         

        });

        MessagingCenter.Subscribe<StopLongRunningTaskMessage>(this, "StopLongRunningTaskMessage", message => {
            if (IsJobServiceOn())
                _jobScheduler.Cancel(1);
        });
    }


    private bool IsJobServiceOn()
    {
        JobScheduler scheduler = (JobScheduler)GetSystemService(JobSchedulerService);

        if (scheduler.GetPendingJob(1) != null)
            return true;
        else
            return false;
    }

The JobScheduler works fine as long as the application is not swiped out or closed entirely. I really do not know why the application crashes when it is restarted after it was swiped out from the recent app list.

Thanks for help in advance.
Samo

Bindable property is not found. Why?

$
0
0

I have a DataTemplate which uses the ExtendedFlexLayout developed David Britch:

<br /> <controls:ExtendedFlexLayout ItemSource="{Binding TagButtons}" Direction="Column"><br /> &lt;controls:ExtendedFlexLayout.ItemTemplate><br /> <DataTemplate x:DataType="utility:PictureTagInformation"><br /> <ViewCell><br /> <Grid Padding="4"><br /> <Button Text="{Binding TagText}" Command="{Binding ViewCommand}" /><br /> <controls:FontAwesomeButton Command="{Binding DeleteCommand}" Text="{x:Static controls:Icon.FATimes}"/><br /> </Grid><br /> </ViewCell><br /> </DataTemplate><br /> &lt;/controls:ExtendedFlexLayout.ItemTemplate><br /> </controls:ExtendedFlexLayout><br />

But ItemSource is always highlighted in the designer with 'Cannot resolve symbol 'ItemSource''. Our app also fails at runtime with ' Property ItemSource is not found or does not have an accessible getter'

The definition in David's class looks fine:

<br /> public static readonly BindableProperty ItemsSourceProperty = BindableProperty.Create(<br /> nameof(ItemsSource),<br /> typeof(IEnumerable),<br /> typeof(ExtendedFlexLayout),<br /> propertyChanged: OnItemsSourceChanged);</p> <pre><code> public IEnumerable ItemsSource { get => (IEnumerable)GetValue(ItemsSourceProperty); set => SetValue(ItemsSourceProperty, value); }

So what gives?

UITEST : check if text appeared in given seconds

$
0
0

I need to check that the text should appeared on screen in 2 seconds .
If it appeared in 2 seconds then test should pass
else test should fail.

Viewing all 77050 articles
Browse latest View live


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