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

I can't type commas in an numeric entry binded to a decimal value

$
0
0

This is really really strange.

I have an entry binded to a ´decimal´ value with a default value (which comes from server):

    <Entry Text="{Binding AmountToPay}" Keyboard="Numeric" />

And I see the value correctly, but if I remove the value and I try to type a different value, I can't introduce a comma. For example, I can't introduce 12,25, but I can introduce 12.

Do somebody know what is happening?


Fresh solution Xamarin.Android.Support.v4 compatibility issues out of the box?

$
0
0

I just created a new solution in VS 2017: Xamarin.Forms Masterdetail with .NET standard. What I have installed:
SDKs for Android 4.4-8.1 (Kitkat to Oreo)
Nuget packages for .NET standard library, Xamarin.Forms (both up to date)

If I try to install support.v4 or v7 I immediately get a LOT of compatibility errors like:

Xamarin.Android.Support.v4 27.0.2 is not compatible with netstandard2.0
Xamarin.Android.Support.Design 27.0.2 is not compatible with +monoandroid70

I can't even update the nuget packages. What do?

Open File - Android 8 or higher - without FileProvider

$
0
0

So I'm with a problem that's been a really annoying problem. So i want to open a file that I recived from a web service, and i already can, in lower andorid version's. I see that to fix the problem I could use FileProvider, but I can't install Xamarin.Android.Support.v4 in the main project because it causes this error:

Error NU1202 Package Xamarin.Android.Support.v4 27.0.2.1 is not compatible with netstandard2.0 (.NETStandard,Version=v2.0). Package Xamarin.Android.Support.v4 27.0.2.1 supports: monoandroid81 (MonoAndroid,Version=v8.1) AppQ4evo C:\Users\Tiago Dias\source\repos\AppQ4evo\AppQ4evo\AppQ4evo\AppQ4evo.csproj 1

So my question is, Firstly if there is a way to use the FileProvider with or without this package but with this not compatiblati solved, or secondarily if there is a way to open the file without the FileProvider.

Thanks for any help.
Best regards,
Tiago Dias

MobileServiceClient intermittent Precondition failed error

$
0
0

I have a Xamarin forms app with uses MobileServiceClient for Azure offline sync. I am intermittently getting a MobileServciePushFailedException which just gives me a 412 preconditon failed when I try and update a record. I have been unable to get any more specific information than this, the app does not catch a MobileServicePreconditionFailedException.
The application is still in development so there should not be a conflict as I am the only user accessing the database, however, I do have the Azure database syncing to an on-site database, is it possible that the sync is changing the record and this is what is causing the error?

XamlReader

$
0
0

Why I do not see in my code XamlReader?

Object xamlObj = XamlReader.Load(xaml);

I'm using 1.4 and PCL Library.
Thanks.

Values vanished/refreshed on swiping more than 4 content pages inside carousel page or tabbed page

$
0
0

I am working on a xamarin forms project which have a carousel page container, and content pages as its children are created dynamically on different condition checks. (Minimum 8 children in my case)

Let's take the mentioned minimum case. I enter some values in entry/picker controls in the 1st child and then navigate/swipe pages till 5th child. When I came back to the first child page, the values I entered/selected are now vanished/refreshed.

I have noticed that carousel page saves only 3 pages data in it. i.e. (Left Page, Current Page and the Right Page). And Tabbed page saves 4 pages data.

I want the values to stay in the child page where I entered whether I navigate to the last most page or in the middle and navigate back to that page.

I have googled via the letters as "Carousel page/ Tabbed page Saved states" etc. but unable to find something useful.

So, I need to know the property name/ method name etc. by which xamarin forms setting the limit of carousel page as 3 and tabbed page as 4.
My requirement is to save and retrieve all children page states in carouselpage.

Waiting for your response.

Thanks.

SearchBar changes color if initial state is invisible

$
0
0

I add 2 search bars with the same color. One is visible, second is not:

<SearchBar Text="Visible" BackgroundColor="Lime" Margin="0, 100, 0, 0"></SearchBar>
<SearchBar x:Name="SearchBar1" IsVisible="false" BackgroundColor="Lime"></SearchBar>
<Button Text="Show" Clicked="Handle_Clicked" HorizontalOptions="Center" VerticalOptions="CenterAndExpand"></Button>

Make second visible on button click:

async void Handle_Clicked(object sender, System.EventArgs e)
{
    SearchBar1.IsVisible = true;
}

As a result I have the second search bar in dark green, not lime as expected

[XF/iOS] FFImageLoading sometimes fails to show image when UIViewController is presented

$
0
0

@DanielL I'm presenting a custom UIViewController on top of RootViewController through a dependency service call in Forms. MainPage of my Forms app is a simple ContentPage (i.e. no navigation or tab pages). I have noticed that calling ImageService.Instance.LoadUrl() sometimes fails to load the image into a UIImageView even though the Success() method is called. This happens intermittently. The fix for me was to call ImageService.Instance.LoadUrl() in ViewDidAppear(), but this means that the image will be shown only after modal page animation is finished.

What is the recommended way to load images into a UIImageView on iOS? @DanielL, do you know why I'm having this issue?


can i make app. Calculates the number of sentences ,Which I have already identified.

$
0
0

can i make app. Calculates the number of sentence if i say The sentences The number of times
Which I set before Select
ex : hi developers (3).
In this condition when i say "microphon" hi developers hi developers hi developers 3 time Gets
in action like message view for example

How to implement a calendar view in Xamarin forms??

$
0
0

Please i need urgent help!
I want to implement a calendar in my mobile app. I have tried various nugets but i'm not getting what i want.
Any ideas??
Attached are images of what i want to achieve and what i have so far.

Livereload problem with Reactive libraries

$
0
0

I am having errors below when I try to use livereload. I believe that it is conflicting with Akavache library i am using.
Akavache is referencing System.Reactive (>= 4.0.0) while Livereload System.Reactive (>= 3.0.0)...I am not sure why it should be the problem as there is no upper limit on versions.

Does anyone know what could be the solution here? below suggestion doesnt solve the problem and more and more errors are appearing.

Livereload doesnt have any issue tracker and Microsoft guys are keep ignoring my question I raised on twitter and gitter :) I dont know what is the deal with them.

    4>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1830,2): 
error XA2002: Can not resolve reference: System.Reactive.Linq, referenced by System.Net.Mqtt. 
Please add a NuGet package or assembly reference for System.Reactive.Linq, or remove the reference to System.Net.Mqtt.
    4>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1830,2): 
error XA2002: Can not resolve reference: System.Reactive.Linq, referenced by Xamarin.Live.Reload. 
Please add a NuGet package or assembly reference for System.Reactive.Linq, or remove the reference to Xamarin.Live.Reload.

Binding controls to a property on the Page

$
0
0

I've got a page which has a property. At the moment I'm setting up the page in the code behind but want to clean up the solution and use data binding to the property items and having the data binding in XAML.

<ContentPage.Content >
    <StackLayout Spacing="12" Padding="30,0"   >

        <input:RadioButtonGroupView  x:Name="RBG1" SelectedItemChanged="RBG1_SelectedItemChanged" >
            <input:RadioButton x:Name="RB1" Text="RB2" TextFontSize="20"  BackgroundColor="red" TextColor="White"  />
            <input:RadioButton x:Name="RB2" Text="Option 2" TextFontSize="20"  BackgroundColor="silver" TextColor="black" />
            <input:RadioButton x:Name="RB3" Text="Option 3" TextFontSize="20"  BackgroundColor="green" TextColor="White"  />
            <input:RadioButton x:Name="RB4" Text="Option 4" TextFontSize="20"  BackgroundColor="blue" TextColor="White" />
        </input:RadioButtonGroupView>

        <Button Text="{Binding Source=MyProperty,Path=MyProperty1  }"></Button>
    </StackLayout>
</ContentPage.Content>

and the code behind is

public partial class RadioGroup : ContentPage
{
    public Class1 MyProperty { get; set; }

    public RadioGroup ()
    {
        InitializeComponent ();
        //RBG1.BindingContext("")

        MyProperty = new Class1();  //Just for demo purposes to set the property


        RB1.Text = MyProperty.MyProperty1;
        RB2.Text = MyProperty.MyProperty2;
        RB3.Text = MyProperty.MyProperty3;
        RB4.Text = MyProperty.MyProperty4;        
    }        

}

So I'm setting the Text attribute on RB1,2,3,4 in the code behind but and trying to do it using something in the XAML

but can't seem to find any simple example of this - any assistance ?

[Android] How to show fullscreen overlay without the status bar

$
0
0

I need to show a fullscreen overlay (could be a modal ContentPage or a Grid on the same page) which hides the status bar. The previous/parent page should keep its status bar when the overlay is dismissed. The problem is, on Android, hiding and showing the status bar causes a relayout of the page so, for example, when I dismiss the overlay, the previous page will have to show its status bar and during that process its content gets shifted down. iOS doesn't have this problem as the status bar is already laid on top of the page content.

How can I toggle the status bar on and off on Android without causing page relayout? I have thought about using a translucent status bar, but this seems to mess up the adjust resize functionality of the soft keyboard as editable content does not move over the soft keyboard when it is visible.

Any best example codes for implementation of class mirroring and partial classes in Xamarin Form?

$
0
0

I am unable to access methods defined in partial classes in Android or other projects from shared code and also how to implement class mirroring, please show me some working examples. Thank you.

Design-Question: I need some input for better representation

$
0
0

Hello all,

I am writing an app, which contains a userprofile. The user shall be able to give some data about himself. It works and this is fine, but I think the UI is boring and not very appealing. This is frustrating to me. The problem is, that I do not have ideas to improve the view. I found some samples (a facebook-clone, a instagram clone and some more), which seem to look okay for me, but my app is not a social media app, so I can not use that way of showing the userprofile. Find attatched the screenshot of my app. It would be very nice, if some of you could share with me some ideas to improve the view.

Thank you for input :-)


How to set a different color for statusBar and navBar

$
0
0

Hello everyone,

Here is a screenshot of what I'm trying to achieve.

Right now, I've a generic style which set both background and foreground color. Something like this

<Style TargetType="NavigationPage">
   <Setter Property="BarBackgroundColor" Value="{StaticResource MyBackgroundColor}" />
   <Setter Property="BarTextColor" Value="{StaticResource MyForegroundColor}" />
</Style>

It works great but I'd like to have a different status bar color than the navbar color. Is it possible from Xamarin Forms ?
If it's not, did anyone already do that with custom renderer and is willing to help me with a link or some code ?

Thanks !! Have all a good day

Update app version

$
0
0

Hi ,
How can i redirect the user to update the app on playstore or appstore if the current version does not match the latest version available.
I am trying to use:-
if (currentVersion == AppVersion.Text)
{
var install = await DisplayAlert("Update Your App", "To get access to the latest features and a better experience", "Update", "Skip");
}

How to get BindingContext reference from a custom Cell?

$
0
0

Hi all,

Considering the XAML bellow, I have a page (StorePage) and ListView which has a DataTemplateSelector that renders different templates.
Inside I have a button that must call a command declared in the page's ViewModel.

The questions is: How can I get the page's BindingContext reference inside ?

Example:

<?xml version="1.0" encoding="UTF-8"?>

<ContentPage.Resources>
    <ResourceDictionary>
        <DataTemplate x:Key="ProductTemplate">
            <controls:ProductCell>
                <local:ProductListItemTemplate />
            </controls:ProductCell>
        </DataTemplate>
        <DataTemplate x:Key="MapTemplate">
            <ViewCell>
                <local:LocationTemplate />
            </ViewCell>
        </DataTemplate>

        <local:StoreTabTemplateSelector x:Key="TabTemplateSelector"
            Template1="{StaticResource ProductTemplate}"
            Template2="{StaticResource MapTemplate}"/>
    </ResourceDictionary>
</ContentPage.Resources>

<StackLayout Spacing="0">
    <ListView  x:Name="ListView"
        ItemsSource="{Binding Items}"
        ItemTemplate="{StaticResource TabTemplateSelector}"
        RefreshCommand="{Binding RefreshCommand}"
        IsRefreshing="{Binding IsRefreshing}"
        HasUnevenRows="True" 
        CachingStrategy="RecycleElement">
        <ListView.Behaviors>
            <b:EventToCommandBehavior EventName="ItemAppearing" 
                                              Command="{Binding LoadMoreCommand}" 
                                              EventArgsParameterPath="Item" />
        </ListView.Behaviors>
    </ListView>
</StackLayout>

Issue while populating ListView with data that comes from an url

$
0
0

This app gets the device coordinates, what can take some seconds. Then it makes a request to an url that does some calcs and echoes a string where each property is separated by ',' and each item by '/'.
So I split the result and use foreach to loop by the items. As you can imagine, it takes a while and before things are ok the UI is completed but the data is not binding since it's not done yet, and it gets worst, because some times the app crashs throwing "Array index out of bounds" exception, it's because the foreach is reached without had received the result of the url request. I almost forget, at android emulator it works, I think it's because it runs really slowlly here, so the delay to url response doesn't matter too much but at a real device the UI is very fast so this problem happens.
I lost about 3 days with this, I'm loosing my hair, I really would apreciate if anybody could help me on this. God bless you.

Example of data that comes from url:

3,Name1,25/1,Name2,39/5,Name3,52/4,Name4,360

XAML File:

    <ScrollView>
        <StackLayout Orientation="Horizontal">
            <ListView x:Name="ListViewLista" ItemsSource="{Binding .}" ItemTapped="ListViewLista_ItemTapped">
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <ViewCell Height="30">
                            <ViewCell.View>
                                <StackLayout BackgroundColor="#eee" Orientation="Vertical" HeightRequest="30">
                                    <StackLayout Orientation="Horizontal" HeightRequest="30" Padding="0,6,0,0">
                                        <Image Source="example_com/img.png" HeightRequest="30" WidthRequest="30" Margin="5,0,5,0" VerticalOptions="Center" />
                                        <Label Text="{Binding Nick}" HorizontalOptions="StartAndExpand" TextColor="Black" VerticalOptions="Center" />
                                        <Label Text="{Binding Distancia}" HorizontalOptions="EndAndExpand" TextColor="Black" Margin="0,0,8,0" VerticalOptions="Center" />
                                    </StackLayout>
                                </StackLayout>
                            </ViewCell.View>
                        </ViewCell>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>
        </StackLayout>
    </ScrollView>

Code Behind .cs:

        public partial class Listar : ContentPage
        {
            public Listar ()
            {
                InitializeComponent();
            }

            protected override async void OnAppearing()
            {
                string resultRequest= await GetOnlineUsers();

                Usuarios ListaUsers = new Usuarios();
                BindingContext = await ListaUsers.GetDefaults(resultRequest.Split('/'));
            }

            public class Usuarios
            {
                public async Task<List<Usuario>> GetDefaults(string[] UsuariosArgList)
                {
                    List<Usuario> lista = new List<Usuario>();
                    int i = 0;
                    foreach(string each in UsuariosArgList)
                    {
                        string[] DataInfo = each.Split(',');
                        lista.Add(new Usuario(){
                            Index = i,
                            DatabaseDeviceId = int.Parse(DataInfo[0]),
                            Nick = DataInfo[1],
                            Distancia = DataInfo[2]
                        });
                        i++;

                       //for debug purpose Console.WriteLine(each);

                    }
                    return lista;
                }
            }

            public class Usuario
            {
                public int Index { get; set; }
                public int DatabaseDeviceId { get; set; }
                public string Nick { get; set; }
                public string Distancia { get; set; }
            }


            private async Task<string> GetOnlineUsers()
            {
                try
                {
                    using (WebClient browser = new WebClient())
                    {
                        string resultado = await browser.DownloadStringTaskAsync("example_com/getUsers.php?lat=" + GetLatitude() + "&lon=" + GetLongitude() + "&raiokm=20000.0");
                        return resultado;
                    }
                }
                catch (Exception)
                {
                    throw;
                }
            }

how to share datatemplate as resourcedictionary between pages?

$
0
0

I have listview with a swipetemplate as below

    <ResourceDictionary
      <DataTemplate   x:Key="SwipeTemplate">

                <ffimageloadingsvg:SvgCachedImage Grid.Row="0"
                               Style="{StaticResource ImgSwapStyle}" 
                               Source="delete.svg" >
                    <ffimageloadingsvg:SvgCachedImage.GestureRecognizers>
                        <TapGestureRecognizer
                            Command="{Binding Path=BindingContext.OnDeleteClick, Source={x:Reference Name=list}}"
                            CommandParameter="{Binding .}"                       
                        />
                    </ffimageloadingsvg:SvgCachedImage.GestureRecognizers>
                </ffimageloadingsvg:SvgCachedImage>

        </DataTemplate>
</ResourceDictionary>

      <sfListView:SfListView x:Name="list"  BackgroundColor="White" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand" 
             ...
                                           SelectedItem="{Binding SelectedItem, Mode=TwoWay}"  
                                           LeftSwipeTemplate="{StaticResource SwipeTemplate}">

Basically if SwipeTemplate is defined in the contentpage's resourcedictionary it works but i want to use it shared for all my pages where i have listview, therefore i need to have it in a merged dictionary. So once i defined resourcedictionary globally, it wont work. because of Source={x:Reference Name=list}.
Although all my listview's are called list, it doesnt work. So how I reference and bind it in a global resourcedictionary?

Viewing all 89864 articles
Browse latest View live


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