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

Add badges Count in the navigation bar using Xamarin Forms


Could not install package 'Xamarin.GooglePlayServices.Base 42.1021.1'

$
0
0

Hi Team,

I have tried to install the NuGet Packages to Xamarin.Forms PCL Project, But the reference is successfully installed in root project but not installed in Android, iOS and etc. I got the following error information. Any solution for this?

Could not install package 'Xamarin.GooglePlayServices.Base 42.1021.1'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.5,Profile=Profile111', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

Dev express datagrid for Xamarin forms

$
0
0

Did anyone know how to use DevExpress.Mobile.Grid in xamarin forms( .net standard) project?

Listview Not binding through ViewModel

$
0
0

I have my viewmodel a below -

public class LeadershipViewModel
{
private PfsServiceArea _oldProduct;
public ObservableCollection Products { get; set; }
public LeadershipViewModel()
{
Products = new ObservableCollection();
var PFSArea = new PfsServices().GetPFSServiceArea("Leadership");
if (PFSArea.Count > 0){
foreach(PfsServiceArea pf in PFSArea){
Products.Add(pf);
}
}
}

    public void ShowOrHidePoducts(PfsServiceArea product)
    {
        if (_oldProduct == product)
        {
            // click twice on the same item will hide it
            product.ShowDescription = false;
            product.ShowDisplay = true;
            UpdateProducts(product);
        }
        else
        {
            if (_oldProduct != null)
            {
                // hide previous selected item
                product.ShowDescription = true;
                product.ShowDisplay = false;
                UpdateProducts(_oldProduct);
            }
            // show selected item
            product.ShowDescription = true;
            product.ShowDisplay = false;
            UpdateProducts(product);
        }

        _oldProduct = product;
    }

    private void UpdateProducts(PfsServiceArea product)
    {
        var index = Products.IndexOf(product);
        Products.Remove(product);
        Products.Insert(index, product);
    }

And I have binded it with listview like below -
Private LeadershipViewModel leader = new LeadershipViewModel();
sicCodeList = new CustomListview(ListViewCachingStrategy.RetainElement)
{
HorizontalOptions = LayoutOptions.StartAndExpand,
VerticalOptions = LayoutOptions.EndAndExpand,
ItemTemplate = sicDataTemplate,
SeparatorVisibility = SeparatorVisibility.None,
Margin = new Thickness(-5, 0, 0, 0),
BindingContext = leader

        };
        sicCodeList.HasUnevenRows = true;
        //sicCodeList.BindingContext = leader;
        sicCodeList.SetBinding(ListView.ItemsSourceProperty, "Products");
        sicCodeList.ItemTapped += (sender, e) => OnItemTapped(sender, e);

I can see 4 items in leader but they are not visible in the listview. Can someone tell me why is this?

Xamarin.Forms.Mac GestureRecognizer not working

$
0
0

Hello there,

I've got a StackLayout which has a GestureRecognizer attached. When I click that StacKLayout in UWP, the Recognizer gets fired, but on MacOS it doesn't. Is this a Bug or still not implemented?

SlFilename.GestureRecognizers.Add(new TapGestureRecognizer() { Command = new Command(ChooseNewFilename) });

Also I tried this with no success:

<StackLayout.GestureRecognizers> <TapGestureRecognizer Tapped="Handle_Tapped" /> </StackLayout.GestureRecognizers>

Maybe someone knows a little more about that issue.

Thanks a lot!

how to save mapbox data offline

$
0
0

I want to save mapbox data offline, how can i do this

problem with listview scrolling items overlapping with headers in xamarin forms

$
0
0

I am problem with listview items. Items are overlapping with headers.
Here is my code.

<ListView
ItemsSource="{Binding List}"

    IsGroupingEnabled="True">
        <ListView.ItemTemplate>
            <DataTemplate>

                <ViewCell>
                    <StackLayout Orientation="Horizontal" HeightRequest="80">
                       <Grid HeightRequest="80">
                             <Grid.RowDefinitions>
                                   <RowDefinition Height="*" />
                                   </Grid.RowDefinitions>
                             <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="25*" />
                                    <ColumnDefinition Width="25*" />
                                    <ColumnDefinition Width="25*" />
                                    <ColumnDefinition Width="25*" />
                              </Grid.ColumnDefinitions>
                               <Label Text="{Binding Name}" VerticalOptions="Center" Grid.Row="0" Grid.Column="0" />
                                       <ctrls:CheckBox  Grid.Row="0" Grid.Column="1" IsChecked="{Binding IsChecked1}" BorderImageSource="checkborder" CheckedBackgroundImageSource="checkcheckedbg" CheckmarkImageSource="checkcheckmark" />   
                                       <ctrls:CheckBox  Grid.Row="0" Grid.Column="2"  IsChecked="{Binding IsChecked2}" BorderImageSource="checkborder" CheckedBackgroundImageSource="checkcheckedbg" CheckmarkImageSource="checkcheckmark" />   
                                       <ctrls:CheckBox Grid.Row="0" Grid.Column="3" IsChecked="{Binding IsChecked3}" BorderImageSource="checkborder" CheckedBackgroundImageSource="checkcheckedbg" CheckmarkImageSource="checkcheckmark" />   

                          </Grid>    
                        <!--<StackLayout HorizontalOptions="FillAndExpand" Spacing="1" Orientation="Horizontal" HeightRequest="80">
                            <Label Text="{Binding Name}" FontSize="Medium" TextColor="#005569" VerticalOptions="Center" />
                            <ctrls:CheckBox VerticalOptions="Center"  IsChecked="{Binding IsChecked1}" BorderImageSource="checkborder" CheckedBackgroundImageSource="checkcheckedbg" CheckmarkImageSource="checkcheckmark" />   
                                <ctrls:CheckBox VerticalOptions="Center"  IsChecked="{Binding IsChecked2}" BorderImageSource="checkborder" CheckedBackgroundImageSource="checkcheckedbg" CheckmarkImageSource="checkcheckmark" />   
                                <ctrls:CheckBox VerticalOptions="Center"  IsChecked="{Binding IsChecked3}" BorderImageSource="checkborder" CheckedBackgroundImageSource="checkcheckedbg" CheckmarkImageSource="checkcheckmark" />   

                        </StackLayout>-->
                    </StackLayout>                        
                </ViewCell>
            </DataTemplate>
        </ListView.ItemTemplate>
        <ListView.GroupHeaderTemplate>
            <DataTemplate>
                <ViewCell>
                    <RelativeLayout HeightRequest="80"   BackgroundColor="#E2F5F9">
                        <Label Text="{Binding Title}"
                           FontSize="Large"
                           RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.1}"
                           RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0, Constant=6}"  />
                        <Image x:Name="StateImage" PropertyChanged="StateImage_PropertyChanged"
                           Source="{Binding StateIcon}" 
                           RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.8}"/>
                        <RelativeLayout.GestureRecognizers>
                            <TapGestureRecognizer Command="{Binding Source={x:Reference currentPage}, Path=BindingContext.HeaderClickCommand}"   CommandParameter="{Binding .}"/>
                        </RelativeLayout.GestureRecognizers>
                    </RelativeLayout>
                </ViewCell>
            </DataTemplate>
        </ListView.GroupHeaderTemplate>
    </ListView>

Please find the attachment for your reference

CoreMethods.PushPageModel not working

$
0
0

@MichaelRidland , after calling CoreMethods.PushPageModel nothing happens, no exception is thrown and the page I am trying to push is not displayed. Can you please demystify for me? Thanks.


ListView does not take all the space inside Grid

$
0
0

Hello folks,

I start developing in Xamarin, and I have a problem with my MasterPage, and more precisely with my ListView which doesn't take all the space provided by the Grid. Just the first element of my ListView is displayed and to see the others there is a scrollbar.

Here is the code :

    <?xml version="1.0" encoding="utf-8" ?>
    <ContentPage xmlns="xxxx://xamarin.com/schemas/2014/forms"
                 xmlns:x="xxxx://schemas.microsoft.com/winfx/2009/xaml"
                 xmlns:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms"
                 prism:ViewModelLocator.AutowireViewModel="True"
                 xmlns:ViewModels="clr-namespace:MyApp.ViewModels"
                 xmlns:ViewsNavigation="clr-namespace:MyApp.Views.Navigation"
                 x:Class="MyApp.Views.Navigation.MasterPage"
                 xmlns:ffSvg="clr-namespace:FFImageLoading.Svg.Forms;assembly=FFImageLoading.Svg.Forms">

        <ContentPage.Content>
            <Grid BackgroundColor="Transparent" VerticalOptions="FillAndExpand">
                <Grid.RowDefinitions>
                    <RowDefinition Height="100" />
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>
                <Grid>
                    <Label Text="M. Tytyroot" TextColor="Black" FontSize="Large" Grid.Row="0"/>
                    <ListView ItemsSource="{Binding Functionnalities}" SeparatorVisibility="None" Grid.Row="1">
                        <ListView.ItemTemplate>
                            <DataTemplate>
                                <ViewCell>
                                    <ViewCell.View>
                                        <StackLayout Orientation="Horizontal" HorizontalOptions="Start" Margin="20,10,20,0">
                                            <ffSvg:SvgCachedImage Source="{Binding IconPath}" HeightRequest="30" WidthRequest="30" Margin="0,0,10,0"/>
                                            <Label Text="{Binding Title}"/>
                                        </StackLayout>
                                    </ViewCell.View>
                                </ViewCell>
                            </DataTemplate>
                        </ListView.ItemTemplate>
                    </ListView>
                </Grid>
            </Grid>
        </ContentPage.Content>

    </ContentPage>

What is the problem?

Thanks in advance

Where did the packages.config in android project go ?

$
0
0

Hello guys I found out that when create a new xamarin.Forms project you get a netstandard project, which is cool, but regarding the android project I do not get packages.config file .
I believe this is causing a problem when trying to install some nuget packages specifically "Xamarin.Facebook.Android" package .

So is there an easy way to convert the project to be able to use packages.config instead of including the packages inside the proj file ?

Grid layout clipped off bottom; Not clipped after phone orientation changed.

$
0
0

I have a grid layout which is clipped off at the bottom.

After rotating the phone to horizontal or vertical, the clipping is then fixed and doesn't come back, no matter what orientation the phone is.

So it looks like something is going on during the initialisation, but I can't at all see where.

Most annoying is that it was working fine before. No idea what I changed though. It's a pretty complex page.

Has anyone else encountered an issue like this?

Thanks.

NullReferenceException when Binding to an Entry control on Android

$
0
0

Greets,

I've created a ViewModel and implemented the INotifyPropertyChanged interface. I only have one property, a string called "Name". I have the following code in the constructor of my ContentPage class:

XamlViewModel viewModel = new XamlViewModel(); this.BindingContext = viewModel; InitializeComponent(); viewModel.Name = "Hello World!";

The 'Name' property calls my OnPropertyChanged() method which in turn calls the PropertyChanged event on the interface. Inside the ContentPage element in the XAML, I have the following single line:

<Entry Text="{Binding Name, Mode=TwoWay}" />

When changing the name property as I did above, the call to PropertyChanged throws a NullReferenceException. I've verified that the ViewModel, property name and event are all non-null, so it appears to be something internal to the binding when the notification is raised.

Is there something that I am doing incorrectly?

Regards,

Joe

toolbar back button

$
0
0

I want to change the navigation of back button in toolbar. I have 3 pages main page, login page and profile page. After successful login it is navigated to profile page. Form profile page when back button is clicked it navigates back to login page, but i need to navigate to main page. Please do let me know how can I solve this.

Customize picker popup on XF?

$
0
0

Is there any way to either decrease the font size or increase the window size of the picker's popup window?

I have some long text that's cutoff when making a selection.

How can I make an overlay MasterBehavior for a page for iOS?

$
0
0

I want that the menu from iOS to look like the one on the Android...

I think I need to write this, but what there?

     public partial class MainPage : MasterDetailPage
    {
            public MainPage()
            {

                InitializeComponent();

                switch(Device.RuntimePlatform)
                {
                    case Device.iOS:
                        MasterBehavior =  ********************;
                        break;

                    case Device.Android:
                        MasterBehavior = MasterBehavior.Popover;
                        break;
                }

                InitializeAsync().ConfigureAwait(false);

            }
    }

Error using JwtSecurityToken

$
0
0

Hi
I'm trying to use custom auth taken from the wonderful book written by adrian hall
https://adrianhall.github.io/develop-mobile-apps-with-csharp-and-azure/chapter2/custom/

But I'm in trouble with the next code in IHttpActionResult Post([FromBody] User body)
.....
System.IdentityModel.Tokens.Jwt.JwtSecurityToken token = Microsoft.Azure.Mobile.Server.Login.AppServiceLoginHandler.CreateToken(
.....

I get an error "Reference to type JwtSecurityToken claims is defined in 'System.IdentityModel.Tokens.Jwt,, but it could not be found"
If I downgrade the nget System.IdentityModel.Tokens.Jwtback to 4.0.20622.1351 I can solve: but how can I solve if I want use the vers. 5.0 ??
Tnx

TargetFrameworkVersion I need V7.1 not v8

$
0
0

Hello

I am beginner Xamarin but I practice C # windowsforms for years

I installed only what connects Android 7.1 but I get this error

The $(TargetFrameworkVersion) for FormsViewGroup.dll (vv8.0) is greater than the $(TargetFrameworkVersion) for your project (v7.1). You need to increase the $(TargetFrameworkVersion) for your project.

The version 8 does not interest me I wish the version 7.1 as well on the emulator as on live player

My problem is that I can not find a trace of the v8 in the configuration of my project

How can I configure my project on version 7.1?

thanks in advance

ASMX service very slow on first call

$
0
0

I have an ASMX service. Proxy class uses SoapHttpClientProtocol Invoke().

The first request from my app is very slow (0.5-2 minutes). The next requests are fast (1 second). This is regardless of HTTPS or HTTP.

A packet sniffer shows that it takes 17 seconds from I call the first request, until my app sends the first packet.

Output window:

03-23 10:28:50.018 D/Mono ( 2358): Image addref Mono.Security[0xd1221ba0] -> Mono.Security.dll[0xd126ff00]: 2
03-23 10:28:50.018 D/Mono ( 2358): Prepared to set up assembly 'Mono.Security' (Mono.Security.dll)
03-23 10:28:50.018 D/Mono ( 2358): Assembly Mono.Security[0xd1221ba0] added to domain RootDomain, ref_count=1
03-23 10:28:50.019 D/Mono ( 2358): AOT: image 'Mono.Security.dll.so' not found: dlopen failed: library "/data/app/com.example.MyApp-1/lib/x86/libaot-Mono.Security.dll.so" not found
03-23 10:28:50.019 D/Mono ( 2358): AOT: image '/usr/local/lib/mono/aot-cache/x86/Mono.Security.dll.so' not found: dlopen failed: library "/data/app/com.example.MyApp-1/lib/x86/libaot-Mono.Security.dll.so" not found
03-23 10:28:50.020 D/Mono ( 2358): Config attempting to parse: 'Mono.Security.dll.config'.
03-23 10:28:50.020 D/Mono ( 2358): Config attempting to parse: '/usr/local/etc/mono/assemblies/Mono.Security/Mono.Security.config'.
03-23 10:28:50.020 D/Mono ( 2358): Assembly Ref addref System[0xe577af80] -> Mono.Security[0xd1221ba0]: 2
Loaded assembly: Mono.Security.dll [External]
03-23 10:28:50.020 D/Mono ( 2358): Assembly Ref addref Mono.Security[0xd1221ba0] -> mscorlib[0xea20a340]: 52
03-23 10:28:50.036 D/Mono ( 2358): Assembly Ref addref Mono.Android[0xe5779780] -> System[0xe577af80]: 14

By the way, when I use HttpWebRequest and manually write SOAP envelope and parse XML it is much faster even the first time (2-3 seconds). But much more work to maintain, so I rather not use this method.

Label position and text alignment

$
0
0

Hi,

I try to right align text under Label but can't find how do this. I try to make 3 label like this :

Label 1 | Label 2 | Label 3

Here is my layout

<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="BasicForm.MainPage">
    <ContentPage.Content >

            <StackLayout Spacing = "0" Padding="10, 40, 10, 40" BackgroundColor="Green" Orientation="Horizontal" HorizontalOptions="FillAndExpand" VerticalOptions="Start">
                <Label x:Name="start" Font="Large" Text="t" HorizontalOptions="FillAndExpand" VerticalOptions="Center"></Label>
                <Label x:Name="middle" Font="Large" TextColor="Red" Text="e" HorizontalOptions="Center" VerticalOptions="Center"></Label>
                <Label x:Name="end" Font="Large" Text="st" HorizontalOptions="FillAndExpand" VerticalOptions="Center"></Label>
            </StackLayout>

    </ContentPage.Content>
</ContentPage>

Label 2 contain only one letter so it have to be on center of the screen. Label 1 is the start of the word (align right) and Label 3 the end of the word.

Any ideas for a workaround when sizing incorrect for Entry in ScrollView in Grid on UWP

$
0
0

I have a complex page layout that involves a Grid into which I dynamically insert other Layouts/Views. On iOS and Android, this works fine, but on UWP I hit a problem when inserting an Entry (nested in a ScrollView) that is bound to a non-Empty string. In that situation, the height of the Entry does not take into account the FontSize of the text in the Entry.

I've simplified the code down to the following, where an instance of BugUWPEntryBindingPageView gets pushed onto the navigation stack.
If the Entry is bound to ValueOne (initially a non-empty string) the height of the Entry is incorrect when the Entry is added to the Grid.
If the Entry is bound to ValueTwo (initially an empty string) the height of the Entry is correct.

This looks like a Xamarin.Forms bug to me (I'm using XF 2.4.0), but (other than always starting with an empty string and later setting the correct value in the ViewModel) has anybody got any ideas for a workaround? (I don't want to wait for Xamarin to release a fix before getting this particular page working as expected)

using Xamarin.Forms;

namespace ViewsUsingXamarinForms
{
    public class BugUWPEntryBindingViewModel
    {
        public BugUWPEntryBindingViewModel()
        {
            ValueTwo = string.Empty;
            ValueOne = "123";
        }

        public string ValueOne { get; set; }
        public string ValueTwo { get; set; }

    } // public class BugUWPEntryBindingViewModel

    public class BugUWPEntryBindingPageView : ContentPage
    {
        private static readonly BugUWPEntryBindingViewModel ViewModel = new BugUWPEntryBindingViewModel();

        private Grid _grid;

        protected override void OnAppearing()
        {
            _grid = new Grid
            {
                BackgroundColor = Color.White,
                HorizontalOptions = LayoutOptions.Fill,
                VerticalOptions = LayoutOptions.FillAndExpand,
                ColumnDefinitions = new ColumnDefinitionCollection
                {
                    new ColumnDefinition { Width = GridLength.Star },
                },
                RowDefinitions = new RowDefinitionCollection
                {
                    new RowDefinition {Height = GridLength.Auto },
                    new RowDefinition {Height = GridLength.Star }
                },
            };

            _grid.Children.Add(
                new Button
                {
                    Text = "Add/replace entries",
                    BackgroundColor = Color.Blue,
                    TextColor = Color.White,
                    Command = new Command(OnAddEntries)
                }, 0, 1, 0, 1);

            BindingContext = ViewModel;
            Content = _grid;
        }

        private void OnAddEntries()
        {
            Entry entry = new Entry
            {
                FontFamily = "Verdana", //DeviceWrapper.DefaultFontFamily,
                FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Entry)),
            };
            entry.SetBinding(
                Entry.TextProperty,
                new Binding(
                    nameof(BugUWPEntryBindingViewModel.ValueOne),
                    BindingMode.TwoWay,
                    null,
                    string.Empty));
            _grid.Children.Add(
                new ScrollView
                {
                    Content = new StackLayout
                    {
                        Children =
                        {
                            entry
                        }
                    }
                }, 0, 1, 1, 2);
        }
    }
}
Viewing all 58056 articles
Browse latest View live


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