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

Request permissions do not continue execution on Android

$
0
0

Hello,

When I request the permissions on Android, the permission windows appear and once they are accepted, the code stops are execution. The application does not crash, there is no except, just a freeze of code execution.
Can you help me ?

try{

    PermissionStatus camera_status = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.Camera);
    PermissionStatus storage_status = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.Storage);
    PermissionStatus location_status = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.Location);

    if (camera_status != PermissionStatus.Granted || storage_status != PermissionStatus.Granted || location_status != PermissionStatus.Granted)
    {
        Dictionary<Permission, PermissionStatus> results = await CrossPermissions.Current.RequestPermissionsAsync(new[] { Permission.Camera,* Permission.Storage, Permission.Location });
        camera_status = results[Permission.Camera];
        storage_status = results[Permission.Storage];
        location_status = results[Permission.Location];
    }

    if (camera_status != PermissionStatus.Granted || storage_status != PermissionStatus.Granted || location_status != PermissionStatus.Granted)
    {
        await Application.Current.MainPage.DisplayAlert("ERREUR", "Vous devez autoriser l'application à accéder à votre appareil photo et votre localisation !", "ok");
        if (Device.RuntimePlatform == Device.iOS)
            CrossPermissions.Current.OpenAppSettings();
    }
}catch(Exception e)
{
    string resulttest = e.Message;
}

Thanks,


How to get Android App Activity X and Y Co-Ordinates on screen ?

$
0
0

If My Android App visible area starting point Will be (0,500) pointer location On screen, How can I get this Starting Pointer location in code, Like If we want Android.Views.View ScreenLocation means We can use View.GetScreenLocation() method, Like that I needs to get Android App activity Visible Area ScreenLocation. If anyone knows suggest possible ways.

Xamarin.forms Android ActivityIndicator Animation hanging issue

$
0
0

Xamarin.forms ActivityIndicator Animation hanging issue occurred in Android when application main thread is busy. But this issue did not occur for iOS and activityIndicator animation run properly. Anyone, please let me know the cause of this in Android only.

My code like below:
XAML

<ContentPage.Content>
        <StackLayout>
            <Button Text="GO TO NEW PAGE" Clicked="Button_Clicked"/>
             <ActivityIndicator Color="Maroon" IsRunning="true" />
        </StackLayout>
    </ContentPage.Content>

CS:

        private void Button_Clicked(object sender, EventArgs e)
        {
            for (int i = 0; i < 100000; i++)
            {
                Console.WriteLine(i);
            }

            Navigation.PushAsync(new NewPage());
        }

Steps to reproduce:

1)Run this code
2)Click GO TO NEW PAGE

OnNavigatedFrom with MasterDetailPage

$
0
0

Hi,
I'm making an app with Xamarin.Forms and Prism and I need to pass through the OnNavigatedFrom of the view I'm in at the moment when navigating using the masterdetail page.
I'm using the NavigateAsync method to navigate from the masterdetail page but it navigate to the requested view without passing throug the onnavigatedfrom of the view i'm in.

Is there any way to navigate from the menu passing through the onnivagatedfrom?

Thanks

Desktop Apps : Change Cursor on hover

$
0
0

This question is only for Xamarin Forms apps for macOS Desktop & WPF targets

When the mouse HOVERS over the element (especially buttons / link button / image buttons), the user expects the mouse cursor to change to something like Hand Cursor.

How can one achieve this effect?

Note: the same XAML page is there for mobile devices.

How to DownLoad Network Image And Save Image to mobile storage

$
0
0

How to DownLoad Network Image And Save Image to mobile storage

Xamarin Forms 3.3.0 error: No property, bindable property or event found for UWP

$
0
0

I met strange error for UWP from following xaml:

<ContentPage.ToolbarItems>
    <ToolbarItem Text="{Binding [SelectData]}" Command="{Binding AddNewDataCommand}">
      <ToolbarItem.Icon>
        <OnPlatform x:TypeArguments="FileImageSource" iOS="data.png" UWP="Assets/data.png"/>
      </ToolbarItem.Icon>
    </ToolbarItem>
    ...
</ContentPage.ToolbarItems>

When compile, I got:

No property, bindable property, or event found for 'UWP', or mismatching type between value and property.

Why ?

Converter Binding for Label

$
0
0

Hi,

I have a label, and I want the label to display different things depending on the bool value returned from a function in my ViewModel.
Let's say the function is called getConnection() - how do I bind to it so that the style will change based on the result?

I'm 99% sure the rest of the code/markup will run, I just need to bind to the return value of the function in my ViewModel. I've marked with ???? where this code needs to go.

<Label.Style>
    <x:Binding ?????????????>
        <Binding.Converter>

            <services:BoolToObjectConverter x:TypeArguments="Style">
                                                        <services:BoolToObjectConverter.TrueObject>
                                                            <Style TargetType="Label">
                                                                <Setter Property="Text" Value="Connected" />
                                                                <Setter Property="TextColor" Value="White" />
                                                            </Style>
                                                        </services:BoolToObjectConverter.TrueObject>

                                                        <services:BoolToObjectConverter.FalseObject>
                                                            <Style TargetType="Label">
                                                                <Setter Property="Text" Value="Not Connected" />
                                                                <Setter Property="TextColor" Value="Gray" />
                                                            </Style>
                                                        </services:BoolToObjectConverter.FalseObject>
            </services:BoolToObjectConverter>

        </Binding.Converter>
    </x:Binding>
</Label.Style>

Thanks!


Text inside image

$
0
0

I have a grid inside a grid.
I want 3 images with text inside them in inner grid align horizontally.
How can I achieve it ?

How to stop ScrollViews resetting content to the first item after pushing and popping another page?

$
0
0

On ContentPages containing ScrollViews, if a new page is pushed onto the navigation stack, and later popped to reveal the original page again, on iOS the ScrollViews on that original page have their contents scrolled to the top again instead of showing the items that were visible when the new page was pushed. On Android and UWP, the position of the content is maintained.

Does anybody have a solution that prevents iOS resetting ScrollViews back to the top in this scenario? If it also stops the same thing happening when the orientation of the device changes that would be a bonus.

XF/iOS: Using AutoSize and ForceUpdateView for expandable editor causes keyboard to hide

$
0
0

Good morning,

I have an Editor in a ListView in Xamarin Forms. I wanted it to expand vertically as I enter more lines; so I set the below on the Editor class constructor:

AutoSize = EditorAutoSizeOption.TextChanges;

This solved the problem outside of a ListView but on iOS the ViewCell height didn't expand with the Editor. So I set the below on the OnPropertyChanged / Height event:

var viewCell = [Get View Cell from obj code];
viewCell.ForceUpdateSize();

This worked! But.. in iOS every time it calls ForceUpdateSize() it hides the keyboard, I assume perhaps because the control loses focus but I'm still investigating.

Has anyone encountered this and solved it already?

Thanks!

How can I set page animation boolean to false using Prism NavigateAsync()?

$
0
0

How can I turn on page transition animation when using Prism NavigateAsync()? The Xamarin.Forms PushAsync() has a Boolean you can set to false, east as that. How can I do that in Prism?

How to log unhandled exception

$
0
0

I have following code in my Xamarin Forms project. I used SentryErrorLog to log exception and saved exception message to pp device locally. I have tested following code and the logging is successful. But I found when there is an unknown exception causing App crashed, there is no log in Sentry and in ExternalStorageDirectory. The unknown exception caused the App shutdown and popup an message "{App name} has stopped".

Because there is no log of the exception, so I don't know how to investigate it. And this exception only happens sometimes, it's hard for me to find the reason. So I want to know if I missed any code to catch the exception? Or sometimes the Android closes the App before the App triggers the exception event handler?

    public override void OnCreate()
    {
        base.OnCreate();

        ravenClient = SentryErrorLog.CreateRavenClient();
        AndroidEnvironment.UnhandledExceptionRaiser += AndroidEnvironment_UnhandledExceptionRaiser;
    }

    private void AndroidEnvironment_UnhandledExceptionRaiser(object sender, RaiseThrowableEventArgs e)
    {
        ravenClient.LogException(e.Exception);
        LogExceptionLocally(e.Exception);
    }

    private void LogExceptionLocally(Exception e)
    {
        // Log to ExternalStorageDirectory
    }

Xamarin.Forms vs Flutter

$
0
0

Hi all
Thomas Burkhart has posted an interesting small review to Flutter (a relative new challenger to .forms) including his personal compare between .forms and Flutter.

As the link was included in the “Weekly Xamarin” newsletter and there also already were articles to Flutter published in the visuals studio magazine (links see below), I think, it’s O.K. to publish this thread here...

As I think, this is interesting for many users, I post the link here:
https://www.burkharts.net/apps/blog/flutter-the-new-kid-on-the-block/?utm_campaign=Weekly+Xamarin&amp;utm_medium=email&amp;utm_source=Weekly_Xamarin_150

Further, also Aloïs Deniel (another Xamarin user) has posted detailed information’s to Flutter a longer time ago here:
https://aloisdeniel.github.io/flutter-introduction/

I think, both postings together will give a good overview to Flutter (from the point of view of Xamarin users).

Link #1 to article in visual studio magazine:
https://visualstudiomagazine.com/articles/2017/12/04/flutter-challenges-xamarin.aspx

Link #2 to article in visual studio magazine:
https://visualstudiomagazine.com/articles/2018/03/01/flutter-xamarin.aspx

Link to a further “high level” comparison Xamarin / Flutter and React native:
http://blog.novoda.com/react-native-flutter-xamarin-a-comparison/

@ThomasBurkhart and @AloisDeniel
First, many thanks for your good work! :smile:

@ThomasBurkhart:
I can fully agree with your findings regarding the “Xamarin tool-chain”.
My personal opinion (without testing Flutter):

  • Looks very promising and interesting (especially “It just works”, fast build time, very fast start-up).
  • Negative points for me are: it seems that there is no integration in VS professional (MS will know the reason for), no direct interface to the device functions, future not secured, no direct support for build iOS on a windows machine

I will definitely keep an eye on Flutter and - as soon as my nerves are completely destroyed with Xamain.Forms - give it a try.

Thanks again

Maybe, also other users want to share their opinions here....?

mscorlib conflict

$
0
0

I created a new xamarin forms app for android and ios and the code generated by visual studio does not even compile. I get this error:

No way to resolve conflict between "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" and "mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e". Choosing "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" arbitrarily.

This bug has been there for about a month and none of the solutions I have found anywhere, including this forum, have worked. Does anyone know how to solve this?

The real question is, how in hell is Microsoft so stupid that they would have a tool where their generated code does not even compile?


How can I develop an app which will communicate with SQL server database residing in GoDaddy?

$
0
0
Hello everyone, I want to develop an app which will allow user to login using his or her credentials. The app will communicate with SQL server database residing in GoDaddy account. I learnt that it requires a web service to do so, no direct communication is possible or it is possible, but allowing a direct connection exposes the connection string containing the user ID and password, residing in the device.

I need your help and the best practices. Any PDF or video showing me the steps in doing so, will help.

Thanks in advance.

How to convert Base64 Image String to FileImageSource in xamarin forms?

$
0
0

My attached images are stored into local database as a Base64 String,I want to show the data to the ImageCarousel(Nuget plugin to view image sliding) View.so how to convert the base64 string to FileImageSource

here is my code
ObservableCollection imageSources = new ObservableCollection();
FileImageSource imageaData= FileImageSource.FromStream(() => new MemoryStream(Convert.FromBase64String(data)));
imageSources .Add(imageData);

how to convert base64 to FileImageSource?

xamarin form : how to change label with stepper

$
0
0

i want to increment or decrement value of label based on stepper value change, but stuck here. Here is my code kindly check it

            <ListView x:Name="mylistview"


              >
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <ViewCell>


                                    <StackLayout HorizontalOptions="StartAndExpand">

                                        <Label HorizontalOptions="Center"   Text="{Binding Qty, StringFormat='Qty. {0:N}'}" FontSize="11"
                                       TextColor="Black" />

                                        <Stepper ValueChanged="stepper_ValueChanged"   Minimum="0" Maximum="10" x:Name="stepper" Value="{Binding Qty}" Increment="0.1" HorizontalOptions="LayoutOptions.Center" VerticalOptions="LayoutOptions.CenterAndExpand"  />


                                    </StackLayout>


                        </ViewCell>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>

Xamarin Forms Entry does not allow comma in Numeric Keyboard

$
0
0

Hi. Xamarin Forms version is 2.3.5.255-pre5. No matter Entry is bound to decimal or string property, Numeric keyboard allows only dot input. Tried with English and German language on phone. Even tried forcing German locale in app.
Then, in native Xamarin Android, tried this approach:
Used EditText with following attributes:

Then EditText opened numeric keyboard, and both dot and comma inputs were allowed and shown both in keyboard and EditText.
Then, in Forms, made custom Entry renderer with:
Control.InputType = InputTypes.NumberFlagDecimal;
Control.KeyListener = DigitsKeyListener.GetInstance("1234567890.,");
(Entry bound to string property, trying to simualete edittext setting explained above).
Comma is accepted in this way:
When it is typed, keyboard does not show it
e.g. 23,3, keyboard shows 233
After keyboard is closed, entry has 23,3 inside.
Any proposal? Comma should be shown also while typing in numeric keyboard.

How to get the children of a ContentPage or in a View?

$
0
0

Hello,

Is there a way to get the children (controls) contained in a ContentPage or in a View?

Thanks in advance!!

Viewing all 89864 articles
Browse latest View live


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