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

Watermarking an image

$
0
0

I need to be able to add a text watermark to an image basically a date/time stamp. Is there a good cross platform way to do this?


Bubble up BindableProperty from a child control into parent control

$
0
0

I just can't seem to figure this one out.

At the moment I'm building my own component made up of Xamarin.Forms controls, it looks something like this.

MyComponent : StackLayout
Label
Switch

I want to have the text bindable property from the Label available on the MyComponent, same with the Switch bindable property.

I'm wondering what's the best way to achieve this? I have a few solutions but I'm sure there's some recommended techniques?

Thanks

How to add resources to custom xaml ViewCell

$
0
0

Hi all.
As you know in xaml for each content page you can specify it's resource dictionary and use them like this

    <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="MyClass"
                 xmlns:local="clr-namespace:MyProject.Forms;assembly=MyProject">
        <ContentPage.Resources>
            <ResourceDictionary>
                 <local:InverseBoolConverter x:Key="inverse" />
                 <local:BoolToOpacityConverter x:Key="opacity" />
                 <local:InverseBoolToOpacityConverter x:Key="inverseOpacity" />
            </ResourceDictionary>
         </ContentPage.Resources>
        <ContentPage.Content>
            <StackLayout Padding="0,20,0,5" IsVisible="{Binding IsNetworkAvailable, Converter={StaticResource inverse}}">
                ......
            </StackLayout>
        </ContentPage.Content>
    </ContentPage>

I'm also used to create ListView cell templates in separate xaml file to reuse them in different xaml pages. However I didn't find a way to use ResourceDictionary in my custom ViewCell xaml. I tried something like this

<ViewCell
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    x:Class="MyListCell"
    xmlns:local="clr-namespace:MyProject;assembly=MyProject">
    <ViewCell.Resources>
        <ResourceDictionary>
                 <local:BoolToOpacityConverter x:Key="opacity" />
                 <local:InverseBoolToOpacityConverter x:Key="inverseOpacity" />
         </ResourceDictionary> 
    </ViewCell.Resources>
</ViewCell>

However I get runtime exception that ViewCell doesn't have Resources property. Anyone knows how to achieve this? My pain purpose is being able to use converters in custom ViewCell xaml, and perhaps there is other way of doing that. Please don't comment that you can use custom property on BindingContext and place the converted data into that property instead of using converter, I know that. But I don't want to create custom property when the best practice in MVVM is creating converter. Any ideas?

[Android] Color.Default based on Context

$
0
0

So in my custom renderer, I have a piece of code that is to update the TextColor of an EditText.

private void SetTextColor()
{
    if (Element.TextColor == Color.Default)
    {
        var e = new EditText(Context);
        NativeView.EditText.SetTextColor(e.TextColors);
    }
    else
    {
        NativeView.EditText.SetTextColor(Element.TextColor.ToAndroid());
    }
}

As you can see, if the default color is set to Default, I new up an EditText based on the Context and then use it's TextColors property. This is working just fine, however I'd like to know how to make the Color.Default property Context aware. In other words, it needs to know the theme and set itself accordingly.

If I were to use the following snippet along with a light theme, the TextColor would disappear since "Color.Default" is white.

private void SetTextColor()
{
    if (Element.TextColor == Color.Default)
    {
        NativeView.EditText.SetTextColor(Color.Default.ToAndroid());
    }
    else
    {
        NativeView.EditText.SetTextColor(Element.TextColor.ToAndroid());
    }
}

Xamarin auth and windows phone

$
0
0

Hi,

I built the expreminental branch of xamarin auth for Windows phone.
I created a pagerenderer in my Windows project and manage to get auth.GetUI(). This is of type Uri. I don't knoz zhqt to do with it. I tried the following but NavigationService is null. Does anyone know how I can display that Facebook UI on Windows phone?
Tks.

`protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.Page> e)
{
base.OnElementChanged(e);

        var auth = new OAuth2Authenticator(
            clientId: BattleQuiz.App.Instance.OAuthSettings.ClientId, // your OAuth2 client id
            scope: BattleQuiz.App.Instance.OAuthSettings.Scope, // The scopes for the particular API you're accessing. The format for this will vary by API.
            authorizeUrl: new Uri(BattleQuiz.App.Instance.OAuthSettings.AuthorizeUrl), // the auth URL for the service
            redirectUrl: new Uri(BattleQuiz.App.Instance.OAuthSettings.RedirectUrl)); // the redirect URL for the service

        auth.Completed += (sender, eventArgs) =>
        {

            if (eventArgs.IsAuthenticated)
            {
                var acc = eventArgs.Account;
                AccountStore.Create().Save(acc, "Facebook");
                BattleQuiz.App.Instance.ChangeUSer(acc.Username);
                MessagingCenter.Send<BattleQuiz.App>(BattleQuiz.App.Instance, "Authenticated");
            }
            else
            {
                // The user cancelled
            }
        };

        PhoneApplicationPage p = new PhoneApplicationPage();
        this.Children.Add(p);
        Uri uri = auth.GetUI();
        p.NavigationService.Navigate(uri);
    }`

Xamarin.Forms and IdentityServer3, how to achieve a successful connection?

$
0
0

I've been stuck like 4 days trying to authenticate using IdentityServer3 (OpenID Connect) with no success. I already tried Xamarin.Auth and also IdentityModel with no success.

So far, the only response I got is "invalid_request" each time doing a "correct request" (I mean, when the endpoint successfully redirects to my redirect uri).

Anybody has samples or any approach I can use with Xamarin.Forms (or using dependency service/Custom Render)?

Xamarin.Forms for UWP Preview Now Available

$
0
0

Many in our community have been asking about Xamarin.Forms for Universal Windows Platform support, and today, we are very happy to bring that request to life. In the past, building apps with Xamarin.Forms required you to create a separate Windows Phone and Store applications, but this preview, available to try today, will enable you to target not only iOS and Android, but also multiple Windows 10 platforms from a single app.

This is your chance to try out the latest-and-greatest in Xamarin.Forms. To help ensure that the next release of Xamarin.Forms is functional, stable, and performant, please let us know about any issues you encounter with the new Xamarin.Forms for UWP preview by filing a bug.

Getting Started

Download and extract the attached zip package that contains the preview NuGet packages. You will have to manually add the folder where the files were extracted to Visual Studio 2015’s NuGet package feed list.

Once you have that setup, you will want to:

  • Add a new Blank App (Universal Windows) project to your Xamarin.Forms solutions
  • Ensure the new project is configured to build and deploy in the configuration manager
  • Add the Xamarin.Forms nuget packages to the newly created project
  • Update Xamarin.Forms NuGets in the other projects, and
  • Configure the application by making the following changes to your UWP project code

Update App.xaml.cs

In OnLaunched under:

rootFrame.NavigationFailed += OnNavigationFailed;

Add:

Xamarin.Forms.Forms.Init (e);

Update MainPage.xaml

Remove all contents from page.

Add new xmlns of:

   xmlns:forms="using:Xamarin.Forms.Platform.WinRT"

Update root to:

<forms:WindowsPage
  ...>
</forms:WindowsPage>

Update MainPage.xaml.cs

    public sealed partial class MainPage
    {
        public MainPage()
        {
            InitializeComponent();
            LoadApplication (new YOUR_NAMESPACE.App());
        }
    }

Reference Your PCL/Shared Project

Don’t forget to add your reference to your portable class library or shared project where your Xamarin.Forms logic resides.

Known Issues
  • The look of some views/pages is not yet finalized.
  • There are a couple known crashers around navigation.
  • Text alignment may not be perfect in some titles.
  • Some things still use the older UAP naming. These will change to UWP.

We can’t wait to get your feedback! :)

Double


App crash immediatly at startup with 'Fatal signal 6 (SIGABRT)' error message

$
0
0

Hi everyone,

I'm a new Xamarin Forms developper (about 2 month old) and I'm facing a big problem when I execute my Xamarin Forms Android application.
I search on the Xamarin forum and on Google for a solution but nothing helped me.
When I execute the application in debug mode (with Visual Studio or Xamarin Studio : same behavior), compilation is ok, application is deployed on my phone and is launching on it.
A black screen appear (as if the Xamarin loading page was going to appear) but suddenly disapear ... but without any handle on Visual Studio and no explicit error message.

This is the complete debug log from Visual Studio :

Android application is debugging.
Could not connect to the debugger.
11-19 16:44:37.434 E/Zygote  (27652): MountEmulatedStorage()
11-19 16:44:37.434 E/Zygote  (27652): v2
11-19 16:44:37.434 I/libpersona(27652): KNOX_SDCARD checking this for 10319
11-19 16:44:37.434 I/libpersona(27652): KNOX_SDCARD not a persona
11-19 16:44:37.474 I/SELinux (27652): Function: selinux_compare_spd_ram, SPD-policy is existed. and_ver=SEPF_GT-I9506_5.0.1 ver=27
11-19 16:44:37.474 I/SELinux (27652): Function: selinux_compare_spd_ram , priority [2] , priority version is VE=SEPF_GT-I9506_5.0.1-1_0039
11-19 16:44:37.474 E/SELinux (27652): [DEBUG] get_category: variable seinfo: default sensitivity: NULL, cateogry: NULL
11-19 16:44:37.474 I/art     (27652): Late-enabling -Xcheck:jni
11-19 16:44:37.544 D/ResourcesManager(27652): creating new AssetManager and set to /data/app/DicTMobile.DicTMobile-1/base.apk
11-19 16:44:37.574 W/monodroid(27652): Using override path: /data/data/DicTMobile.DicTMobile/files/.__override__
11-19 16:44:37.574 W/monodroid(27652): Using override path: /storage/emulated/0/Android/data/DicTMobile.DicTMobile/files/.__override__
11-19 16:44:37.574 W/monodroid(27652): Trying to load sgen from: /data/data/DicTMobile.DicTMobile/files/.__override__/libmonosgen-2.0.so
11-19 16:44:37.584 W/monodroid(27652): Trying to load sgen from: /storage/emulated/0/Android/data/DicTMobile.DicTMobile/files/.__override__/libmonosgen-2.0.so
11-19 16:44:37.584 W/monodroid(27652): Trying to load sgen from: /data/app/DicTMobile.DicTMobile-1/lib/arm/libmonosgen-2.0.so
11-19 16:44:37.584 W/monodroid(27652): Trying to load sgen from: /data/data/DicTMobile.DicTMobile/files/.__override__/links/libmonosgen-2.0.so
11-19 16:44:37.584 W/monodroid-debug(27652): Trying to initialize the debugger with options: --debugger-agent=transport=dt_socket,loglevel=0,address=127.0.0.1:8989,server=y,embedding=1
11-19 16:44:37.634 W/monodroid-debug(27652): Accepted stdout connection: 26
11-19 16:44:38.404 F/        (27652): * Assertion at /Users/builder/data/lanes/2098/3efa14c4/source/mono/mono/metadata/class.c:5078, condition `class' not met
11-19 16:44:38.404 F/libc    (27652): Fatal signal 6 (SIGABRT), code -6 in tid 27652 (bile.DicTMobile)

The problem has muted before this :
- First time a exception was throwed at startup about a missing public constructor on the fist ViewModel loaded (while in fact there was here !)
I search during few hours without success.
- Next day exception disappear as if by magic ! Very strange ! Now application is running well and I can tap on my login button and arrive on my main page and ... finaly crash few seconds later ... I'm amazed !
At this point there is still no handle on any exception on Visual Studio.
Console out give this at end (not the same code but similar) :

E/mono-rt(15933): =================================================================
E/mono-rt(15933): Got a SIGSEGV while executing native code. This usually indicates
E/mono-rt(15933): a fatal error in the mono runtime or one of the native libraries 
E/mono-rt(15933): used by your application.
E/mono-rt(15933): =================================================================
A/libc(15933): Fatal signal 11 (SIGSEGV) at 0x0000001d (code=1)
  • Third day ... i'm exhausted. I don't know neither what nor or look.
    Stable Xamarin Forms 4.0 is out, i decide to update my project, who know, maybe it's my solution ! Hope makes live !
    In fact Xamarin has worked on Forms optimization that made it up to 2 time faster.
    Now my problem appears immediatly ....

I'm becoming crazy, are threre somebody to help me ? Please help !

(I hope my readable English because I'm French)

Adding a picker in XAML

$
0
0

I'd like to add a picker control that has the values 1,2,3,4,5.

I tried the following...

        <Picker SelectedIndex="{Binding NewCriterion.Importance}" >
            <Items>
                <x:String>"1"</x:String> 
                <x:String>"2"</x:String>
            </Items>
        </Picker> 

to no avail. The documentation is a bit sparse on how to do this in XAML. Help?

Remove icon from action bar from xamarin forms android project

$
0
0

Hi,
Can someone help me in removing icon from action bar ?

Thanks,
Ashish jha

How to show loading indicator when webview is loading in XF

$
0
0

Hi,

I am trying to show a loading indicator while my webview is loading up in XF.

I found it's very easy to do with the native API, but not found any correspondent events or such in XF.

Could anyone help?

Regards, T

WPToolkit in Xamarin.Forms

$
0
0

Hello there!

Xamarin´s way to show Pickers (Date, Time, or simple Lists) on Windows-Phone is always fullscreen.
It does not make much sense to go fullscreen if it only has 2 to 5 or 6 entries.
Now there is the WPToolkit which has ListPicker for example.

How can I use that controls from there ?

Card.IO integration

$
0
0

Anyone knows how to integrate Card.IO into Xamarin.Forms Apps?
My company has a new app needs to implements credit card scanning using camera, but I Pretty much have no idea on how to do it.

Any help would be very appreciated.

Thanks,

Ting

Is it support Multiple resolutions for Android and multiple devices for IOS?

$
0
0

Hello Team,

We are planing to use Xamarin.Forms for my below requirement.
I have a requirement that, we need to develop the application for both Android and IOS. For Android it should support for any device (All resolutions for both Mobile and Tablet) and for IOS it should support for all devices.

UI: For any device (Complex UI)
BTLE: For Android and IOS
Data Base: For Android and IOS
Animations: For Android and IOS
Maps: For Android and IOS
Web Services : For Android and IOS

Can we use Xamarin.Forms for this requirement criteria.

Waiting for your positive response.

Thanks in advance.


Create a File Chooser (upload) in Xamarin.Forms

$
0
0

Hi guys,
i'd like to create a file chooser (file upload) in Xamarin.Forms but i don't find nothing. Do you have a solution? Thanks a lot.

Can we develop an application with complex UI which support all resolutions in Android and iOS ?

$
0
0

Hi,

My requirement is to develop the application for all resolutions in Android as well as all devices for iOS with rich User Interface, Which includes MapView,DataBase,WebServices and Peripheral Connectivity with BLE.

Thanks In Advance

How to set Tag for a view inside GetCellCore of CellRenderer ?

$
0
0

I have a Custom CellRenderer ( Android ) for list items in a Xamarin.Forms.ListView.

I am trying to create a custom ViewHolder pattern , so that I can get rid of unnecessary view.FindViewById calls.

Here is my code :

`[assembly: ExportRenderer (typeof (CommentsListItem), typeof (CommentsListItemCellRenderer))]
namespace TCMobile.Droid
{
public class ViewHolder : Java.Lang.Object{
public ImageView commentDeleteImage;
public TextView commentDescription;
public TextView commentAuthor;
public TextView commentModified;
}

public class CommentsListItemCellRenderer : CellRenderer
{

    Android.Views.View view;
    Activity activity = null;
    ViewHolder holder = null;

    private bool assignDelegate = false;



    public CommentsListItemCellRenderer ()
    {
    }

    protected override Android.Views.View GetCellCore (Cell item, Android.Views.View convertView, Android.Views.ViewGroup parent, Android.Content.Context context)
    {
        base.GetCellCore (item, convertView, parent, context);
        assignDelegate = false;

        view = convertView;
        var x = (CommentsListItem)item;

        activity = context as Activity;
        if (view == null) {// no view to re-use, create new
            assignDelegate = true;
            view = activity.LayoutInflater.Inflate (Resource.Layout.TodoCommentsListCell, null);

            holder = new ViewHolder ();
            holder.commentDeleteImage = view.FindViewById<ImageView> (Resource.Id.comments_delete_image);
            holder.commentDescription = view.FindViewById<TextView> (Resource.Id.comments_text); 
            holder.commentAuthor = view.FindViewById<TextView> (Resource.Id.comments_username); 
            holder.commentModified = view.FindViewById<TextView> (Resource.Id.comments_modified);

            view.Tag = holder;

        } else {
            // PROBLEM IN THIS LINE
            holder = (ViewHolder) view.Tag;
        }

        FontHelper.getFontHelper().applyFont(holder.commentAuthor, Constants.FONT_OPEN_SANS_BOLD);
        FontHelper.getFontHelper().applyFont(holder.commentDescription, Constants.FONT_OPEN_SANS_REGULAR);
        FontHelper.getFontHelper().applyFont(holder.commentModified, Constants.FONT_OPEN_SANS_REGULAR);

        holder.commentDescription.Text = x.CommentsText;
        holder.commentAuthor.Text = x.AuthorName;
        holder.commentModified.Text = x.CreatedDate;

        if (x.EditEnabled) {
            holder.commentDeleteImage.Visibility = Android.Views.ViewStates.Visible;
        } else {
            holder.commentDeleteImage.Visibility = Android.Views.ViewStates.Gone;
        }

        if (assignDelegate) {
            holder.commentDeleteImage.Click += delegate {
                if (x.EditEnabled) {
                    MessagingCenter.Send<CommentsListItemCellRenderer, string> (this, "DeleteComment", x.CommentId);
                }
            };
        }

        return view;
    }



}

}
`

The problem is , in case of reused views i.e. when convertView is not null , I am getting an InvalidCastException in the line ,
holder = (ViewHolder) view.Tag;

I have also tried holder = view.Tag as ViewHolder .
But it returned null value .
Also, I do not know how the view.SetTag(int, Object) method can be useful in this case.

Is there any other way to do this , within the Cell Renderer ?

Android Project Causing Visual Studio to Hang

$
0
0

I need some help in how to debug this issue. I have recently upgraded to Xamarin 4 and now when I open my Xamarin Forms project it will hang just after initializing the Android project. If I comment out the Android Project from the solution, it otherwise loads just fine.

This also happens on another developers PC, so it isn't computer specific and I don't think a reinstall will work in this scenario and I don't want to waste time doing it either.

Does anyone know how to even debug these types of issues? All I have from the Windows Error Logs is

The program devenv.exe version 14.0.23107.0 stopped interacting with Windows and was closed. To see if more information about the problem is available, check the problem history in the Security and Maintenance control panel.
Process ID: 2ae0
Start Time: 01d1236293daa550
Termination Time: 4294967295
Application Path: C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.exe
Report Id: f1ee30f3-8f55-11e5-8328-a4db30edc639
Faulting package full name:
Faulting package-relative application ID:

How to change ImageSource's Resolutions in Xamarin.ios

$
0
0

Hello Team,
Currently i am working on ImageSource in Xamarin.Forms.ios.
I want to display and save image in different resolutions .
can anyone tel me how to do this..?

Viewing all 91519 articles
Browse latest View live


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