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

Custon Render for ToolbarItens

$
0
0

Hello Every body
I need to implement a rounded icon in nav bar like whatsapp photo profile
Can help me please...
How can i do a custon render for toolbaritens round icon


Twoway binding for object properties not working

$
0
0

This is my Xaml

<Image Grid.Column="0" Grid.Row="0" Source="contactIcon.png" />
<Entry Grid.Column="1" Grid.Row="0"  Text="{Binding SelectedContact.FNAME,Mode=TwoWay}" Placeholder="First Name" />
<Entry Grid.Column="1" Grid.Row="1"  Text="{Binding SelectedContact.LNAME,Mode=TwoWay}" Placeholder="Last Name"/>
<Image Grid.Column="0" Grid.Row="2" Source="calIcon.png" />
<Entry Grid.Column="1" Grid.Row="2" Text="{Binding SelectedContact.PHONE,Mode=TwoWay}" Placeholder="Mobile" Keyboard="Telephone"/>
<Image Grid.Column="0" Grid.Row="3" Source="emailIcon.png" />
<Entry Grid.Column="1" Grid.Row="3" Text="{Binding SelectedContact.EMAIL,Mode=TwoWay}" Placeholder="Email" Keyboard="Email"/>
<Entry Grid.Column="1" Grid.Row="4" Text="{Binding SelectedContact.BALANCE,Mode=TwoWay}" Placeholder="Email" Keyboard="Email"/>

Contact model

    public int ID { get; set; }
    public string FNAME { get; set; }
    public string LNAME { get; set; }
    public string PHONE { get; set; }
    public string EMAIL { get; set; }
    public Double BALANCE { get; set; }

ContactViewModel

        private Contact _selectedContact;
        public Contact SelectedContact{get { return _selectedContact; }set{ 
        _selectedContact = value; OnPropertyChanged(); } }

OneWay binding is working but i want twoway binding. If i change the text or modify the text in the firstname entry then it should change the FNAME property of SelectedContact.

How would I make a custom round label renderer auto size to its width of text?

$
0
0

How would I make a custom rounded label renderer resize based on the width of the label inside it? I always want a little space to the left and right of the text.

Implementation of Google Sign-In sdk in xamarin.forms

$
0
0

Hi I am trying to create Google Sign In using the Google Sign In SDK as Google has updated its security restrictions for OAuth flow. They are not going to allow native web-views to initiate OAuth flows. I want to use the Google Sign In Sdk in xamarin forms for both android and ios. If any one has already implemented it then please share the information or code for it.

Issue with Forms 2.4.0.280 on an android [No view found for id 0x1 (unknown) for fragment]

$
0
0

Hello,

After an update of xamarin.forms nuget to 2.4.0.280, I have an issue with an android

Here's stack trace:

09-29 06:50:25.610 E/mono (17500): Unhandled Exception:
09-29 06:50:25.610 E/mono (17500): Java.Lang.IllegalArgumentException: No view found for id 0x1 (unknown) for fragment FragmentContainer{1716c46c #0 id=0x1}
referenceTable GDEF length=670 1
referenceTable GSUB length=7202 1
referenceTable GPOS length=24560 1
09-29 06:50:25.610 E/mono (17500): --- End of managed Java.Lang.IllegalArgumentException stack trace ---
09-29 06:50:25.610 E/mono (17500): java.lang.IllegalArgumentException: No view found for id 0x1 (unknown) for fragment FragmentContainer{1716c46c #0 id=0x1}
09-29 06:50:25.610 E/mono (17500): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1334)
09-29 06:50:25.610 E/mono (17500): at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1569)
09-29 06:50:25.610 E/mono (17500): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1636)
09-29 06:50:25.610 E/mono (17500): at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:758)
09-29 06:50:25.610 E/mono (17500): at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2415)
09-29 06:50:25.610 E/mono (17500): at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2201)
09-29 06:50:25.610 E/mono (17500): at android.support.v4.app.FragmentManagerImpl.optimizeAndExecuteOps(FragmentManager.java:2155)
09-29 06:50:25.610 E/mono (17500): at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2064)
09-29 06:50:25.610 E/mono (17500): at android.support.v4.app.FragmentController.execPendingActions(FragmentController.java:379)
09-29 06:50:25.610 E/mono (17500): at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:607)
09-29 06:50:25.610 E/mono (17500): at android.support.v7.app.AppCompatActivity.onStart(AppCompatActivity.java:178)
09-29 06:50:25.610 E/mono (17500): at md5a32ee3795e82798420962242b26c9524.MvxFormsAppCompatActivity.n_onStart(Native Method)
09-29 06:50:25.610 E/mono (17500): at md5a32ee3795e82798420962242b26c9524.MvxFormsAppCompatActivity.onStart(MvxFormsAppCompatActivity.java:43)
09-29 06:50:25.610 E/mono (17500): at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1220)
09-29 06:50:25.610 E/mono (17500): at android.app.Activity.performStart(Activity.java:5953)
09-29 06:50:25.610 E/mono (17500): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2261)
09-29 06:50:25.610 E/mono (17500): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
09-29 06:50:25.610 E/mono (17500): at android.app.ActivityThread.access$800(ActivityThread.java:144)
09-29 06:50:25.610 E/mono (17500): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
09-29 06:50:25.610 E/mono (17500): at android.os.Handler.dispatchMessage(Handler.java:102)
09-29 06:50:25.610 E/mono (17500): at android.os.Looper.loop(Looper.java:135)
09-29 06:50:25.610 E/mono (17500): at android.app.ActivityThread.main(ActivityThread.java:5221)
09-29 06:50:25.610 E/mono (17500): at java.lang.reflect.Method.invoke(Native Method)
09-29 06:50:25.610 E/mono (17500): at java.lang.reflect.Method.invoke(Method.java:372)
09-29 06:50:25.610 E/mono (17500): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
09-29 06:50:25.610 E/mono (17500): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
09-29 06:50:25.610 E/mono (17500):

There is an example of the issue
https://github.com/JTOne123/XamFormsMvxTemplate/blob/master/MvxForms.sln

PS: If switch back to 2.3.4, everything will be ok

PRISM + Unity Container - Link sdk and user assemblies

$
0
0

Have anyone already configure the linker to work properly with the Microsoft Unity container?
I have an app that is currently in production but at for now i've only use "SDK assemblies only". So i'm trying to reduce the size of this app and linker is the best option but i'm not getting to make it work.

I've already make a test: created a new Prism.Unity app, with the Prism Template Package and the only change that i made was set link to full mode...the app crashes as well.

The error message:

Unhandled Exception:
08-29 13:52:02.485 E/mono    (12194): System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeInitializationException: The type initializer for 'Microsoft.Practices.Unity.ArrayResolutionStrategy' threw an exception. ---> System.InvalidOperationException: Sequence contains no matching element
08-29 13:52:02.485 E/mono    (12194):   at System.Linq.Enumerable.First[TSource] (System.Collections.Generic.IEnumerable`1[T] source, System.Func`2[T,TResult] predicate) [0x00011] in <b5bd9d990a0b4733885e90ca5ec6c0fb>:0 
08-29 13:52:02.485 E/mono    (12194):   at Microsoft.Practices.Unity.ArrayResolutionStrategy..cctor () [0x00014] in <95410a6f72e5460987abb52dc3238a18>:0 
08-29 13:52:02.485 E/mono    (12194):    --- End of inner exception stack trace ---
08-29 13:52:02.485 E/mono    (12194):   at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke (System.Reflection.MonoCMethod,object,object[],System.Exception&)
08-29 13:52:02.485 E/mono    (12194):   at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00002] in <183b200ee49746d48fc781625979428e>:0 
08-29 13:52:02.485 E/mono    (12194):    --- End of inner exception stack trace ---

Picker firing event SelectedIndexChanged on iOS too early

$
0
0

I've been trying to use Forms Picker and it looks like it has different behavior on Android/Windows Phone and on iOS.

https://developer.xamarin.com/api/type/Xamarin.Forms.Picker/

On iOS event SelectedIndexChanged is fired as soon when picker stops scrolling on one of the items.
On other systems, event is fired when user accepts the choice and exits the picker.

This is problematic, because I'd like to make decision based on what user selects, not what picker is showing during selection.

I know no way to get event when user actually touches "Done" on screen.

Forms 1.5
I cannot use 2.0 because of current catastrophic Windows Phone problems.

Title of the content page is not displayed

$
0
0

I have updated to lates version of Xamarin.Forms and title defined in Content page is not displayed in Android. The content page is added correctly:

MainPage = new NavigationPage(new Jobs());

Title is populated by IMarkupExtension that pulls the value from a resource file. At first I thought this might not be working but a quick debugging session proved me wrong. I have also tried to put static text in this property but again, it is not displayed.

Has anything changed in the new version that would break my code?


changing Grid.IsVisible to true: child views remain invisible

$
0
0

I have a GridLayout with some child views in it, and initially the grid is invisible (and collapsed), because I set "IsVisible" to false.
Then I have a button to toggle the visibilty of the grid, and when I toggle it for the first time, ie. set IsVisible=true, the grid is not collapsed any more, but all children in it are not visible, there is just a white background. But when I toggle it again (IsVisible=false) and then again (the second time) to IsVisible=true, all child views are visible. I also tried "grid.ForceLayout()" after setting IsVisible to true, but it has no effect.

Any solution to that ?

Problem with using Grid.IsVisible

$
0
0

Hi there
It turned out the Grid.IsVisible (iOS part) works only one way: when IsVisible=true, it appears.
If set IsVisible=false, it hides but holds the place of the same size it had. Just blank ugly void.
Nevertheless, the Xamarin doc reads:

Setting IsVisible to false will remove the element from the visual tree. The element will no longer take up space in layouts or be eligle to receive any kind of input event

Apparently, it is a bug.
Any clue how to work around?
Thanks.

Entry with numeric/telephone keyboard changing app background color

$
0
0

I'm noticing very odd behavior on Android using Xamarin.Forms. Typing into an Entry with a numeric/telephone keyboard (all other types don't have this issue) darkens the background color. This behavior occurs even on a clean project with nothing but an Entry:

using Xamarin.Forms;

namespace App1
{
    public class App : Application
    {
        public App()
        {
            MainPage = new MainPage();
        }
    }

    public class MainPage : ContentPage
    {
        public MainPage()
        {
            Content = new Entry { Keyboard = Keyboard.Numeric };
        }
    }
}

When the Entry is first focused into, nothing unusual happens. In fact, if you click the tick at the bottom right of the keyboard to close it without entering anything, nothing happens either. But if you type anything (even if you backspace it), the background color of the app changes. It even affects other pages in a navigation stack.

What is the cause of this can how can it be fixed?

ListView databinding just won't work

$
0
0

I have the following page in XAML:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="ht_tp://xamarin.com/schemas/2014/forms"
xmlns:x="ht_tp://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:DietAndFitness.ViewModels"
x:Class="DietAndFitness.Views.FoodDatabasePage">
<ContentPage.Content>
<StackLayout>
<ListView ItemsSource="{Binding FoodItems}" RowHeight="120">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ContentView Padding="5">
<Frame OutlineColor="Accent" Padding="10">
<StackLayout>
<Grid HorizontalOptions="Center">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Label Text="{Binding Name}" FontSize="22" VerticalOptions="CenterAndExpand" HorizontalOptions="Center" Grid.Row="0" Grid.Column="0"/>
<Label Text="{Binding Calories}" FontSize="22" VerticalOptions="CenterAndExpand" HorizontalOptions="Center" Grid.Row="0" Grid.Column="1"/>
</Grid>
<Grid HorizontalOptions="Center">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Label Text="Carbohydrates" Grid.Row="1" Grid.Column="0" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand" FontSize="16"/>
<Label Text="Proteins" Grid.Row="1" Grid.Column="1" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand" FontSize="16"/>
<Label Text="Fats" Grid.Row="1" Grid.Column="2" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand" FontSize="16"/>
<Label Text="{Binding Carbohydrates}" Grid.Row="2" Grid.Column="0" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand" FontSize="16"/>
<Label Text="{Binding Proteins}" Grid.Row="2" Grid.Column="1" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand" FontSize="16"/>
<Label Text="{Binding Fats}" Grid.Row="2" Grid.Column="2" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand" FontSize="16"/>
</Grid>
</StackLayout>
</Frame>
</ContentView>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<Grid HorizontalOptions="Center">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Button x:Name="AddFoodItemButton" BackgroundColor="LightGray" HorizontalOptions="CenterAndExpand" Text="Add" Grid.Row="0" Grid.Column="0" Clicked="AddFoodItemButton_Clicked" />
<Button x:Name="EditFoodItemButton" BackgroundColor="LightGray" HorizontalOptions="CenterAndExpand" Text="Edit" Grid.Row="0" Grid.Column="1" />
<Button x:Name="DeleteFoodItemButton" BackgroundColor="LightGray" HorizontalOptions="CenterAndExpand" Text="Delete" Grid.Row="0" Grid.Column="2" />
</Grid>
</StackLayout>
</ContentPage.Content>

And this is the code behind:

 public FoodItemsViewModel FoodDatabase { get; set; }
      public FoodDatabasePage ()
      {

        InitializeComponent ();
        FoodDatabase = new FoodItemsViewModel(SQLiteConnection.Database);
        BindingContext = FoodDatabase;

    }

    protected override void OnAppearing()
    {
        FoodDatabase.LoadList();
    }

    public void AddFoodItemButton_Clicked(object sender, EventArgs e)
    {
        FoodDatabase.Add();
    }

But my ListView just comes up empty. The only way I've managed to get the list populated is if I do

<ListView ItemsSource="{x:Static local:FoodItemsViewModel.FoodItems" RowHeight="120">
And make the ObservableCollection in my VM static. This is my VM:

     public class FoodItemsViewModel 
      {
       private SQLiteAsyncConnection database;


    public ObservableCollection<GlobalFoodItem> FoodItems { get; set; }


    public FoodItemsViewModel(SQLiteAsyncConnection _database)
    {
        database = _database;

    }

    public async void LoadList()
    {

            FoodItems = new ObservableCollection<GlobalFoodItem>(await database.Table<GlobalFoodItem>().ToListAsync());

    }

    public void Add()
    {
        FoodItems.Add(new GlobalFoodItem("Item"));

    }

}

Even if I make my ObservableCollection static the list still doesn't actually load until I reload the page by navigating to another one.

Furthermore attempting to implement INotifyPropertyChanged in my VM results in StackOverflow exception at the ObservableCollection getter (I already implemented INotifiyPropertyChanged in the GlobalFoodItem class, maybe it has something to do with it?).

Also, here is the github for the project htt_ps://github.com/TJorj/DietAndFitness

I have no idea what's going on anymore. How can I get this thing working properly?

File upload, is this possible?

$
0
0

I have an application that is coming along very nicely. However, looking online one of my app requirements requires the ability to take a photo/small file (.doc,.csv,.pdf), nothing huge.

And upload it to our system. I can do this via a web api 2.0 call or something else.

How can I achieve this in an elegant way?

Thanks in advance!

Development platform hangs very often

$
0
0

My development environment is visual studio community 2017 running on Windows 7, on a "healthy" machine. All updates have been applied to both windows and visual studio. I am developing Xamarin forms for IOS. I have a new MacBook which is the build agent.

My app runs, but I find that when I stop debugging, make a code change, and rerun, visual studio hangs about 1 out of 4 tries. I have to go to task manager and kill it and then restart. Very time consuming and frustrating.

Is there a process I need to follow to make this more reliable?

Local XAML namespace in Shared project

$
0
0

Hello,

I tried to declare a local XAML namespace in my pages in a Shared Xamarin.Forms project like this :

     xmlns:local="clr-namespace:MyProject.Example;assembly=MyProject.Example"

It doesn't work, and that is obvious because a Shared project isn't built but its content is copied in other projects with different assemblies (MyProject.Example.iOS, MyProject.Example.Android, ...).

How can I achieve this ?

Thank you !


Device.Idiom for andriod TV is Phone ! why ?!!

$
0
0

Hello guys ,
As the title says , when I check the Device.Idiom for the android TV it returns that its from type of Phone. Can someone explain this ? Is there a way to know that I am running from a TV ?

Why does my data bind to my listview, but not Fontsize or TextColor?

$
0
0

I set a FontSize property in my viewmodel, then I bind it in my Style, but the Fontsize doesn't trickle down to my listview label. I've also tried binding directly on the listview label, but this doesn't work either. If I hard code my fontsize into the style, it works but I need dynamic fontsize, especially in UWP.

Also, please notice that my data binds properly inside the listview but my TextColor won't bind either. Anything you can think of would be greatly appreciated.

//My Style
      <Style x:Key="settingsLabelStyle2" TargetType="Label" BasedOn="{StaticResource settingsLabelStyle}">
                    <Setter Property="HorizontalOptions" Value="Start" />
                    <Setter Property="VerticalTextAlignment" Value="Center" />
                    <Setter Property="FontSize" Value="{Binding ScoreFontSize}" />
                </Style>


    //Part of my listview
      <DataTemplate>
                                <ViewCell>
                                    <Grid>
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="*" />
                                        </Grid.RowDefinitions>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="7*" />
                                            <ColumnDefinition Width="4*" />
                                            <ColumnDefinition Width="*" />
                                        </Grid.ColumnDefinitions>

                                    <Label Grid.Column="0" Text="{Binding GameDate}"  Style="{DynamicResource DynamicSettingsLabelStyle2}" />
                                            <Label Grid.Column="1"  Text="{Binding PlayerName}"  Style="{DynamicResource DynamicSettingsLabelStyle2}" />
                                            <Label Grid.Column="2"  Text="{Binding Score}"  Style="{DynamicResource DynamicSettingsLabelStyle2}" />
                                        </Grid>
                                    </ViewCell>
                                </DataTemplate>


    //My Fontsize property


            private double scoreFontSize = 20;
            public double ScoreFontSize
            {
                get { return scoreFontSize; }
                set
                {
                    SetProperty(ref scoreFontSize, value);
                    OnPropertyChanged();
                }
            }

Issue when Create new Xaml forms on F# project

$
0
0

Hello All,

I have some issue when create new Xaml forms on F# project, I use Visual Studio for Mac version 7.4.2 (Build 12).

The issue is when I create new Xaml project the namespace of the Xaml and the code behind is not correctly updated and give result like this code:

On the Code behind:

namespace ${SafeUserDefinedProjectName}

open Xamarin.Forms
open Xamarin.Forms.Xaml

type EwsPage() =
    inherit ContentPage()
    let _ = base.LoadFromXaml(typeof<EwsPage>)

The namespace not correct and still give ${SafeUserDefinedProjectName} as result, please help if someone have solution for this case.

Thanks,

Free Xamarin Forms TreeView (All Platforms)

Convert Png to Bitmap (1 bit per pixel)

$
0
0

How to convert png to 1bit per pixel (bit depth =1) image in xamarin forms?
Trying to print the image to WOOSIM printer. I am able to print text but needs to print image. As of now when I print png image it prints random ASCII characters.

Thanks.

Viewing all 75885 articles
Browse latest View live


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