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

How can I pass a ViewCell into custom control?

$
0
0

I'm making a custom control and how can I pass other View into it?

In my case I want to pass in a custom ViewCell to my custom ListView so I could re-use this custom control with different item sources and their proper ViewCells:

<ContentView xmlns="http://xamarin.com/schemas/2014/forms" 
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="Foobar.Base.Views.LazyListView">
    <ContentView.Content>
        <StackLayout>
            <Label Text ="Custom ListView"></Label>
            <CustomListView ItemsSource="{Binding Items}">
                <CustomListView .ItemTemplate>
                   ** <!--Render a custom ViewCell that was passed in to the custom control-->**
                </CustomListView.ItemTemplate>
            </CustomListView >
        </StackLayout>
    </ContentView.Content>
</ContentView>

Should I use something like x:Arguments for it?


iPhone simulators missing from debug device list

$
0
0

I am running Visual Studio 15.9.5 on Windows 10, I have a MacBook Pro with Visual Studio for Mac and all the latest updates, with Xcode 10.1.

In Xcode Preferences/Components, you can see I have installed iOS 10.0 Simulator, 10.1,10.2,10.3.1,11.0,11.1,11.2, 11.3, 11.4, 12.0.

While paired up with the MacBook Pro, in DEBUG mode, I can see all the iPhone 5 and 6's from 10.3 to 12.1 (I am targeting 10.3).
However, in this list, there are no iPhone 7's or above. In the unsupported list, it does some some iPHone 7's, but they are older than 10.3.

Does anyone have some suggestions as to how I can fix this?

Custom fonts don't load in iOS

$
0
0

Custom fonts don't load in Xamarin iOS. As described in the Xamarin documentation from 2013 (https://blog.xamarin.com/custom-fonts-in-ios/), I have done the following (project is attached):

1) Import the font into Resources
2) Set Build Action to "BundleResource" (mistake in the Xamarin documentation)
3) Copy to output directory: "Always Copy"

In FinishedLaunching() in the App Delegate, I iterate through all installed fonts:

foreach (var family in UIFont.FamilyNames)
{
    System.Diagnostics.Debug.WriteLine($"{family}");

    foreach (var names in UIFont.FontNamesForFamilyName(family))
    {
        System.Diagnostics.Debug.WriteLine($"{names}");
    }
}
var fontName = UIFont.FromName("Karbon", 20.0f); // fontName is null

No custom fonts show up, what is the problem here?


Visual Studio Community 2017 for Mac (Preview)
Version 7.1 Preview (7.1 build 1178)
Runtime: Mono 5.2.0.179 (2017-04/4498dc4) (64-bit)

Xamarin.iOS
Version: 10.12.0.5 (Visual Studio Community)

Very strange error

$
0
0

Hi all togehter,
as asked in this thread:

https://forums.xamarin.com/discussion/142159/strange-error-2#latest

I have a very strange error.
As before, running as UWP works perfectly, the problem is only in Android.

After updating all files with NuGet and Visual Studio 15.9.5 i get the following error.

try
{
await Table.PullAsync($"all{Identifier}", Table.CreateQuery()).ConfigureAwait(false);
}

        catch (MobileServicePushFailedException push_ex)
        {
            ShowPushError(this.ToString() + " -> PullLatestAsync", push_ex);
        }

        catch (Exception ex)
        {
            Debug.WriteLine("<PullLatestAsync()>Unable to pull items, that is alright as we have offline capabilities: " + ex);
            return false;
        }      
        return true;

The error raises in await Table...…..
and was catched in catch (Excepiion e)

{System.Net.Http.HttpRequestException} System.Net.Http.HttpRequestException
base {System.InvalidOperationException} System.InvalidOperationException
System.Net.WebExceptionStatus.NameResolutionFailure System.Net.WebExceptionStatus

Help is needed very urgend because i have no idea where to look and what to do...

Thanks in Advance
Peter

Is it possible to use BOTH a Notification Service Extension and Notification Content Extension?

$
0
0

For my application I am using a Notification Service Extension to modify the way the notification is displayed to the user.
I also want to display a photo in its content, for this I understand I would need to use a Notification Content Extension.

Is it possible to use both? I don't really see how that would be.

How can I add a photo in my notification and where would that photo need to reside? Can be it in the Library folder?

How will i Dismiss Picker when i tap wherever

$
0
0

Hi,
i Want to dismiss the picker when i tap on background or wherever

Now my Hamburger and Picker is overlaping

Cannot open pdf document in Pdf viewer

$
0
0

Hi

i am currently trying to open a web pdf in xamarin forms page using following code

Device.OpenUri(new Uri(strWebUrl));

When i click , some pdf's are showing option as "Open with Drive PDF Viewer" . But some pdf's are showing only options of Chrome and IE

Please advice me on this

regards,
Vinay

ScrollViewer vs. Enclosed, how to control who gets the MotionEvents?

$
0
0

I have a somewhat complicated design that has just slammed face first into reality.

I have an ImageView which shows a photo or other bitmap. I have a SketchCanvas which overlaps it, and the user can draw on it. The save functionality combines the bitmap in the ImageView and the Android.Graphics.Path 's that are created, so the user can basically annotate their images, circling the parts they care about and such.

This works great, but sometimes the image is too big for the screen. So I put it inside of a ScrollView. But doing this has caused a problem that was obvious in retrospect, but somehow made it through design.

The problem is, when the user drags their finger across the screen, what happens? Does it draw a line on the image, or does it pan the ScrollView? I have to pick one or the other.

So now I've added a button which is supposed to change whether you are in pan mode (where your finger controls the scrollviewer), and draw mode (where your finger draws lines on the image). My question is, how do I implement this in Android? That is, what is the hook that I should use to control whether the ScrollView or its children are handling the MotionEvent's that the user is creating?


UWP Project throws error after random amount of time

$
0
0

Hi folks

Since the very beginning of Xamarin.Forms every now and then I had this weird issue where the UWP Project, after weeks or months without changes but relatively frequent builds and rebuilds, would just throw an error on build and no amount of rebuild, restarting of VS or deleting of bin and obj folders or even restarting the machine would solve it.

Right now, as last time it broke, it throws this error:
x:Class type 'YourApp.UWP.MaintPage' is not found in 'YourApp'

Every time this happened I started a new project, copied everything over from the old one, made sure that it was working, and then moved the whole folder back, overwriting everything in the process. Looking at Git, nothing's changed, but it works again.

Is there something like clearing a cache that I can do instead? It's quite the pain (and timeconsuming of course) to do this every time.

Is there a Label for Hyperlinks?

$
0
0

Hey there. Is there a Label that can recognize Hyperlinks like Phone numbers, E-Mails and URLs ?

I found this one but it does not work for me. I copy pasted that whole thing.

AwesomeHyperLinkLabel.cs is in my namespacename project.

AwesomeHyperLinkLabelRenderer.cs is in my namespacename.iOS project

then I created an xaml in my namespacename with xmlns:AwesomeHyperLinkLabel="clr-namespace:namespacename"

acts like a usual Label.

Did I miss a step or do I have to configure something myself?

TitleBar on AXML

$
0
0

Hi,
I just new on using XAMARIN on Visual Studio. I would like to ask on how to remove the titlebar on the activity_main.axml

Thanks.

Native linking failed, undefined Objective-C class

$
0
0

Hello Xamarin Folks,
I am stuck with a very unpredictive error form last couple of months.

It all started when I updated my Visual Studio for Mac and other components of Xamarin Platform. I glad one of my team member didn't update and we are all depended on him to generate build for iOS.

Problem:
If I build iOS project with Release configuration/iPhone Device I get following error,

clang : error : linker command failed with exit code 1 (use -v to see invocation)
MTOUCH : error MT5211: Native linking failed, undefined Objective-C class: TAGContainerCallback. The symbol 'OBJC_CLASS$TAGContainerCallback' could not be found in any of the libraries or frameworks linked with your application.
MTOUCH : error MT5211: Native linking failed, undefined Objective-C class: TAGLogger. The symbol '_OBJC_CLASS
$TAGLogger' could not be found in any of the libraries or frameworks linked with your application.
MTOUCH : error MT5211: Native linking failed, undefined Objective-C class: GAILogger. The symbol '_OBJC_CLASS
$_GAILogger' could not be found in any of the libraries or frameworks linked with your application.
MTOUCH : error MT5202: Native linking failed. Please review the build log.

Although the application is working in Debug configuration on iPhoneSimulator.

I tried updating Xamarin.Forms, Xamarin.Forms.Maps, Xamarin.Google.Maps to the latest version in all my relevant project. No success. :neutral:

From my findings: TAGContainerCallback, TAGLogger and GAILogger belong to Maps control or Picker control.

Any information or hint is appreciated.

Background and Foreground app and Push Notifications.

$
0
0

Hello developers,

I'm using the plugin https://github.com/CrossGeeks/FirebasePushNotificationPlugin and https://github.com/winstongubantes/MatchaBackgroundService

The plugin work good, I receive the push notification with background, Foreground and too when the app is closed.

The problem is that plugin FirebasePushNotification, with event OnNotificationReceived detect the event when app is background but don't enters the event, without de event OnNotificationReceived, all it works good! when I receive the push notifacion with mi app the background and I have other code, for example show alert and back the app foreground it works!, the alert it's visible.

I need the following:

My app don't' use commercial, only professional.

When receive push notification and my app is foreground, show alert (it works), when my background app receive push notification with de plugin, show alert (when back foreground app).

Any examples?
Where find information?

Thanks advance.

Picker Custom Renderer not working properly!

$
0
0

I have implemented an custom android renderer for a Picker , just a basic one i found online. But the issue i have found, is when i click the picker to show the dialog options, on the first click it doesn't show the custom changes(default dialog) but when i close the picker option and then click the picker again to show the dialog option, then it shows my custom dialog changes.

I have tried using it with using PickerRenderer = Xamarin.Forms.Platform.Android.AppCompat.PickerRenderer; as well;

Any help would be appreciated thanks.

Stef

renderer added below:

using System;
using System.Linq;
using Android.App;
using Android.Content;
using Android.Widget;
using BindablePicker;
using BindablePicker.Droid;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
using Color = Android.Graphics.Color;
using Orientation = Android.Widget.Orientation;

[assembly: ExportRenderer(typeof(CustomPicker), typeof(CustomPickerRenderer))]
namespace BindablePicker.Droid
{
public class CustomPickerRenderer : PickerRenderer//, ViewRenderer<Picker, EditText>
{

    IElementController ElementController => Element;


    public CustomPickerRenderer(Context context) : base(context)
    {
        AutoPackage = false;

    }


    private AlertDialog _dialog;


    protected override void OnElementChanged(ElementChangedEventArgs<Picker> e)
    {
        base.OnElementChanged(e);
        Control.Click += Control_Click;
    }


    protected override void Dispose(bool disposing)
    {
        if (disposing)
        {
            Control.Click -= Control_Click;
            //var picker = (Picker)Element;
            //picker.PropertyChanged -= Control_Click;
        }


        base.Dispose(disposing);
    }

    private void Control_Click(object sender, EventArgs e)
    {
        Picker model = Element;
        model.Title = "changed";

        var picker = new NumberPicker(Context);

        if (model.Items != null && model.Items.Any())
        {
            // set style here

            picker.MaxValue = model.Items.Count - 1;
            picker.MinValue = 0;

            picker.SetBackgroundColor(Color.Purple);
            picker.SetDisplayedValues(model.Items.ToArray());
            picker.WrapSelectorWheel = false;
            picker.Value = model.SelectedIndex;

        }


        var layout = new LinearLayout(Context) { Orientation = Orientation.Vertical };
        layout.AddView(picker);
        layout.SetBackgroundColor(Color.Purple);

        var titleView = new TextView(Context);

        titleView.Text = "hmmmm";
        titleView.SetBackgroundColor(Color.ForestGreen);

        ElementController.SetValueFromRenderer(VisualElement.IsFocusedProperty, true);

        var builder = new AlertDialog.Builder(Context);
        builder.SetView(layout);

        builder.SetTitle(model.Title ?? "");

        //builder.SetCustomTitle(titleView);
        builder.SetNegativeButton("Cancel  ", (s, a) =>
        {
            ElementController.SetValueFromRenderer(VisualElement.IsFocusedProperty, false);
            // It is possible for the Content of the Page to be changed when Focus is changed.
            // In this case, we'll lose our Control.
            Control?.ClearFocus();
            _dialog = null;
        });
        builder.SetPositiveButton("Ok ", (s, a) =>
        {
            ElementController.SetValueFromRenderer(Picker.SelectedIndexProperty, picker.Value);
            // It is possible for the Content of the Page to be changed on SelectedIndexChanged.
            // In this case, the Element & Control will no longer exist.
            if (Element != null)
            {
                if (model.Items.Count > 0 && Element.SelectedIndex >= 0)
                    Control.Text = model.Items[Element.SelectedIndex];
                ElementController.SetValueFromRenderer(VisualElement.IsFocusedProperty, false);
                // It is also possible for the Content of the Page to be changed when Focus is changed.
                // In this case, we'll lose our Control.
                Control?.ClearFocus();
            }
            _dialog = null;
        });

        Control.Text = "Control";

        _dialog = builder.Create();
        _dialog.DismissEvent += (ssender, args) =>
        {
            ElementController?.SetValueFromRenderer(VisualElement.IsFocusedProperty, false);
        };
        _dialog.Show();
    }

}

}

How to convert c# object to native NSObject

$
0
0

Hi , i am having the object data in which current datasource item is stored in forms. I need to map the item to native item.

NSObject obj = (NSObject) data;

It shows the error as cannot convert object to NSObject and Cast is not applicable .

Anyhelp is appreciated


Problem with Absolute Layout and Overlay Areas

$
0
0

Hi there!

I have a View with list view and, using absolute layout, I created an editor for that list view.

The editor, when visible, overlays itens 2 to 6.

I can tap or press itens 1 and 7 to call the editor.

If I tap itens 2 to 6, nothing happens. The editor, even invisible, block my selection.

Is there a way to fix this problem?

Thanks in advance for any kind of help.

Regards,

Ciro.

Basic Deployment and Build Questions

$
0
0
  1. I create a new project (Xamarin, Blank project). I compile it. My Android phone is plugged into the computer. I start the ADB server. Then I select Deploy and I get a deployment to the Emulator. I don't want that. I want to deploy to the phone. What gives? How do I diagnose? How do I stop deployment to the emulator?

ChangeCanExecute is not working, why?

$
0
0

Hello there!

I have some commands on my ViewModels, and I realized that I can them multiple times at the same time, and is getting me some troubles with updating data from a WebApi.

The basic structure I have is something like:

        private Command _LoadCommand;
        public Command LoadCommand
        {
            get { return _LoadCommand ?? (_LoadCommand = new Command(async() => await ExecuteLoad())); }
        }

        private async Task ExecuteLoad ()
        {
                IsBusy = true;
                SendSignatureToSAP.ChangeCanExecute();

                await DoSomething();

                SendSignatureToSAP.ChangeCanExecute();
                IsBusy = false;
        }

I read about ChangeCanExecute and some documentation about Commands. It doesn't reccoment to call CanExecute(false) because it doesn't trigger an event or something like that. Also, I read that since a not-so-recent version of XF, it can have the value "null" and ChangeCanExecute only puts it into null again, but I don't know if this is true or if it makes sense.

So, what should I do to know if it's doing it right or not?
It's also allowing pages to trigger OnSizeAllocated when I'm in a child page, atop of it.

Thank you!

Reproduce carousel view behaviour/animation/transition to a horizontal scroll view.

$
0
0

Hey developers,
I have so far tried to use a carousel view due to its ease of use and of course its performance. But I tried to show the tail of each UI elements (let's say we've a bunch of cards) whatever the position is as shown in the picture. I've googled a lot and posted another question in this forum but since then I changed the project UI a little bit so I ignored the given solution and now I am on my own again, I resolved it (show the next card's tail or/and the previous), I'll write down the structure I used in XAML but first let me highlight my requirements.
I want to reproduce the behaviour, animation/transition on swiping of the carousel view to my view, because I am actually using a horizontal scroll view with a Flex layout inside.
Here is the structure :

Now I've tried two options :
1- Use of Scrolled event in the scroll view but that hasn't been a great option because it fire the events (animation or transition) after the scroll is done, in my case it should fire the event since scrolling started.
2- Use of SwipeGestureRecognizer on Scrollview, FlexLayout and BoxView : couldn't get a stable behaviour on the 2 first attempts but when I used a BoxView I couldn't get each StackLayout (the StackLayout is my card) inside the BoxView (It wasn't built for that).

Here is my UI after I used a horizontal scroll view :

here is the behaviour I wanted to reproduce to my view :
https://media.giphy.com/media/l0NwH3XDSYhQ6l4TC/giphy.gif

Missing required Icons

$
0
0

Hi,

we have a problem uploading our app to the iOS app store for some days now. Actually it is a Forms App but hope it's still correct in this forum.
The app was working before but since we updated to Mojave and updated some of the Xamarin stuff there seems to be problem in building the asset catalog.
When trying to upload the ipa to the app store we get errors like:

ERROR ITMS-90023: "Missing required icon file. The bundle does not contain an app icon for iPad of exactly '76x76' pixels, in .png format for iOS versions >= 7.0."
ERROR ITMS-90023: "Missing required icon file. The bundle does not contain an app icon for iPad of exactly '167x167' pixels, in .png format for iOS versions supporting iPad Pro."
ERROR ITMS-90023: "Missing required icon file. The bundle does not contain an app icon for iPad of exactly '152x152' pixels, in .png format for iOS versions >= 7.0."

We already deleted bin/obj folders. Recreated the asset catalog. Checked the path in info.plist.
Everything seems to be fine.

I could figure out that the Assets.car that is created in copied to the ipa is empty or includes a default Xamarin Forms image.
I checked my build output and there are two entries related to the Assets.car:

    Copying file from '/Users/.../iOS/obj/iPhone/Release/actool/bundle/Assets.car' to '/Users/.../iOS/bin/iPhone/Release/....iOS.app/Assets.car'

and later:

    Copying file from '/Users/.../iOS/obj/iPhone/Release/Assets.car' to '/Users/.../iOS/bin/iPhone/Release/....iOS.app/Assets.car'

This makes actually no sense to me. The first copies the correct file to the bin path with the related assets. The second seems to copy an empty template file. Does that make sense to anyone? Is it possible to change the build process or is the actool building incorrect?

Any help is appreciated.

Chris.

Viewing all 204402 articles
Browse latest View live


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