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

Globally defined resource is not found at run time

$
0
0

I defined all value converters in App.xaml of the common project. So far all those resources are available everywhere.

But now newly defined resources are not found at run time and the app crashes. Is there any limit on the resources in global ResourceDictionary? If not what could be the reason for them not found. Only the newly defined one is not found. Before the new one defined I had 21 resources in the global ResourceDictionary.

I had to define the new one each views XAML to run the app.

What is the reason for this behavior in Xamarin Forms.


Can you limit a Slider to only allow integer values? (Hopefully snapping to the next integer)

$
0
0

I have a slider I would like to use as a rating feature. I would like the slider to be between 0-5 but only allow integer values. and preferably snap to the next integer. Is this possible?

How to identify the item binded to a button inside a collectionview?

$
0
0

Hi,

I have a collectionview inside another collectionview. In the nested collectionview, I have a button which has data binding binding. I also have a clickedevent for this button. When I click the button the event is fired, but I don't know for item this button has been fired? I am attaching an List<> to the collectionview.

How to get token without open Microsoft authenticator app and to own xamarin app

$
0
0

Hello guys,

I need to integrate MFA with xamarin app. I have downloaded Microsoft authenticator app and register with the user using QR code and its working fine.
Now I have developed my own Xamarin app which is also register on Azure with MFA enable . I want to validate the user without entering any credentials to my xamarin app so I want to get token from my application generated by Microsoft authenticator app without opening it.

Please help !!!

SkiaSharp Canvas to byte array or stream

$
0
0

Hey guys,

What I am trying to do is I have a popup with skiasharp and once the user finished the free drawing and click on save button I want to convert the canvas to byte array or stream and send to the other page and view the image on image control.

My Issue is I don't know how to convert the canvas to byte array. I am using below code

            SKBitmap bitmap = new SKBitmap((int)canvasView.Width, (int)canvasView.Height);
                SKCanvas canvas = new SKCanvas(bitmap);

                // create an image COPY
                //SKImage image = SKImage.FromBitmap(bitmap);
                // OR
                // create an image WRAPPER
                SKImage image = SKImage.FromPixels(bitmap.PeekPixels());

                // encode the image (defaults to PNG)
                SKData encoded = image.Encode();

                // get a stream over the encoded data
                Stream stream = encoded.AsStream();

        //publish new event                
        _aggregator.GetEvent<IncidentRepImageEvent>().Publish(stream);

        //Close the popup               
         NavigationExtension.PopPopupAsync(null, true);

and using this code to view the image on the other page

        ImageSource PhotoStream = (StreamImageSource)ImageSource.FromStream(() => obj);

                Image = PhotoStream;

[App Store] How to solve "ITMS-90809: Deprecated API Usage" issue?

$
0
0

I am working on a new app and I just tried to submit a build to TestFlight, and it worked, but I also got this email response.
The curious thing is that the app does NOT use any web views:

Dear Developer,

We identified one or more issues with a recent delivery for your app, "AWD Service" 1.0 (1). Your delivery was successful, but you may wish to correct the following issues in your next delivery:

ITMS-90809: Deprecated API Usage - Apple will stop accepting submissions of apps that use UIWebView APIs . See https://developer.apple.com/documentation/uikit/uiwebview for more information.

After you’ve corrected the issues, you can upload a new binary to App Store Connect.

Best regards,

The App Store Team

What's the problem??

Searching only after user stop writing in SearchBar

$
0
0

I'm posting this because I assume it could be a problem for others starting with Xamarin Forms too...

The target is... lets suppose I search for "AGUA" (Water in Spanish) of course I don't want to search for "A", "AG", "AGU"... so if you are using Web Services for search or using a large set of data it will increase the performance and improve the user experience of your App...

So essentially my searchBar control name is "buscar" (search in spanish)... so I made this

 int number_of_searches = 0;
 int started_searches = 0;

        public MainPage()
        {
            InitializeComponent();

and then...

 buscar.TextChanged += (o, e) => {
                number_of_searches++;

                Device.StartTimer(TimeSpan.FromMilliseconds(300), () =>
                {
                    started_searches++;

                    if (started_searches < number_of_searches)
                        return false;

                    started_searches = 0;
                    number_of_searches = 0;

                    SearchBar searchBar = (SearchBar)o;

                    Console.WriteLine( "Searching for " + searchBar.Text );

                    // ...

So when the user type the "number_of_searches" will increase...

So lets suppose the user search for "AGUA"

So he/she type "A" and then "G"

at this point number_of_searches will be 2...

The first timer callback supposed to be executed 300ms after the user typed "A" will increase number_of_searches...
So number_of_searches will be 1

so 1 != 2 so return false...

And continue like that until the user finish the word...

BTW It doesn't have to be 300ms, some people consider something like 600 ms is better but for me 300 works...

And as you can see it worked...

If you have a better method please comment about it...

Good luck!

Master detail view with MVVM navigation

$
0
0

Hi,

Is it possible to do the page navigation inside a master detail view without code-behind?

I want the code to navigate from page to page inside a viewModel.

Is the navigationpage bindable? can it be set from inside a viewModel?

Thanks,

Psienaert


NavigationPage.TitleView doesn't center SearchBar

$
0
0

I've added a SearchBar to my NavigationPage toolbar using TitleView, but no matter what I try it doesn't get centered on Android. I have set BackButtonTitle to an empty string ( I only want the back arrow)

I guess the arrow is affecting the starting position of the bar, so it is in fact centered but only the starting point of the bar is from the end of the back arrow. How can I solve my issue?

See image attached

Note: I also tried this, but it's still not perfectly centered:

    <NavigationPage.TitleView>
        <AbsoluteLayout>
            <ImageButton Source="BackArrow.png" 
                        AbsoluteLayout.LayoutFlags="PositionProportional" AbsoluteLayout.LayoutBounds="0, .5, 30, 30"/>
            <SearchBar x:Name="MapSearchID" 
                                Opacity="0.8"
                                HeightRequest="40"  
                                WidthRequest="240"
                                VerticalOptions="Center"
                                SearchButtonPressed="MapSearch"
                   AbsoluteLayout.LayoutFlags="PositionProportional" AbsoluteLayout.LayoutBounds=".5, .5, 100, 44"
                   HorizontalTextAlignment="Center"/>
        </AbsoluteLayout>

    </NavigationPage.TitleView>

Carousal View is override Issue

$
0
0

I'm new in Xamarin's community,
I'm Trying to Implement Hotstar's like carousal using a carousel view in Xamarin forms (4.4 stable version).
My Issue is when carousal view calls in my feed section it displays the previous carousal Images and video on top of it. Please help How I solve this.
I'm Attaching a screenshot showing how it displays in my UI displays

And the same happened on Feed's carousal too. Please help how I solve this.

Tabbed page -> Disable swiping on disabled tab only

$
0
0

Hello,

I have a xamarin forms app that uses tabbed pages. I have extended it and I have custom renderer for it (so I can customize it a bit).
I want to be able to disable a tab so it is not clickable and swipeable but the standard way I am able to swipe and see the page in it.
I am working currently only for the Android version of the app.

How can I achieve this?

Thanks,
Stan

Last 3 items are not displaying in Listview

$
0
0

Xaml code:

<?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="VSS.Pages.CustomerSchedule"
             x:Name="customerSchedulePage">
    <ContentPage.Content>
        <AbsoluteLayout x:Name="customerScheduleLayout" HorizontalOptions="CenterAndExpand">
            <StackLayout x:Name="stackLayout" BackgroundColor="Transparent" Margin="10" VerticalOptions="CenterAndExpand">
                <StackLayout x:Name="BtnNavBarBack" Orientation="Horizontal" HeightRequest="40">
                    <Button BackgroundColor="Transparent" Image="back.png" BorderRadius="10" BorderWidth="2" BorderColor="#375587" Clicked="btnBack" HorizontalOptions="StartAndExpand" WidthRequest="50" HeightRequest="25"></Button>
                    <StackLayout Orientation="Horizontal"  HorizontalOptions="EndAndExpand">
                        <Button  ImageSource="importContacts.png" Clicked="importContactsClick" BackgroundColor="Transparent" WidthRequest="60"></Button>
                        <Button  ImageSource="addContact.png" Clicked="addContactsClick" BackgroundColor="Transparent" WidthRequest="60"></Button>
                        <Button  ImageSource="quickSchedule.png" Clicked="customerQuickSchedule" BackgroundColor="Transparent"  WidthRequest="60"></Button>
                    </StackLayout>
                </StackLayout>

                <StackLayout x:Name="searchBar" Orientation="Horizontal" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand" BackgroundColor="Transparent" HeightRequest="40" Margin="10,15,20,15">
                    <Entry x:Name="searchCustomer" Placeholder="Search Customer" TextChanged ="searchCustomerList" Completed="searchCustomerList"></Entry>
                    <Button x:Name="searchImgBtn"  Clicked="searchCustomerList" BackgroundColor="Transparent"  Image="searchIcon.png" WidthRequest="16" HeightRequest="16"></Button>
                </StackLayout>

                <ListView x:Name="existContacts" HasUnevenRows="True" >
                    <ListView.Header>
                        <Grid BackgroundColor="#1CA9FF">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="7*"></ColumnDefinition>
                                <ColumnDefinition Width="7*"></ColumnDefinition>
                                <ColumnDefinition Width="2*"></ColumnDefinition>
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="40"></RowDefinition>
                            </Grid.RowDefinitions>
                            <Label Text="Customer Name" Grid.Column="0" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand" TextColor="White" Font="15" FontAttributes="Bold"/>
                            <Label Text="Mobile Number" Grid.Column="1" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand" TextColor="White"  Font="15" FontAttributes="Bold"/>
                        </Grid>
                    </ListView.Header>
                    <ListView.ItemTemplate>
                        <DataTemplate>
                            <ViewCell>
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="7*"></ColumnDefinition>
                                        <ColumnDefinition Width="7*"></ColumnDefinition>
                                        <ColumnDefinition Width="2*"></ColumnDefinition>
                                    </Grid.ColumnDefinitions>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto"></RowDefinition>
                                    </Grid.RowDefinitions>
                                    <Button Grid.Column="0" TextColor="Black"  FontAttributes="Bold" Text="{Binding FirstName}" VerticalOptions="CenterAndExpand" HorizontalOptions="CenterAndExpand" BackgroundColor="Transparent" Clicked="customerSchedule" Command="{Binding FirstName}" CommandParameter="{Binding}" Padding="-3"></Button>
                                    <Button Grid.Column="1" TextColor="Black"  FontAttributes="Bold" Text="{Binding MobileNumber}" VerticalOptions="CenterAndExpand" HorizontalOptions="CenterAndExpand" BackgroundColor="Transparent" Clicked="customerSchedule" Command="{Binding MobileNumber}" CommandParameter="{Binding}"></Button>
                                    <Button Grid.Column="2" BackgroundColor="Transparent" Image="{Binding deleteIcon}" VerticalOptions="Center" Clicked="deleteCustomer" CommandParameter="{Binding}"></Button>
                                </Grid>
                            </ViewCell>
                        </DataTemplate>
                    </ListView.ItemTemplate>
                </ListView>
                <!--</StackLayout>-->

                <ActivityIndicator x:Name="actIndicator2" TranslationY="-300"
                    WidthRequest="200" HeightRequest="200" Color="Black"
                    AbsoluteLayout.LayoutBounds="0,0,1,1" AbsoluteLayout.LayoutFlags="All"  
                    HorizontalOptions="Center" VerticalOptions="Center"/>

            </StackLayout>

            <ContentView x:Name="overlay"
                         AbsoluteLayout.LayoutBounds="0, 0, 1, 1"
                         AbsoluteLayout.LayoutFlags="All"
                         BackgroundColor="#C0808080">
                <StackLayout HorizontalOptions="Center" VerticalOptions="Center">

                    <StackLayout x:Name="Alert"   BackgroundColor="#D2D7DD"  HorizontalOptions="StartAndExpand" VerticalOptions="StartAndExpand"  HeightRequest="220"  WidthRequest="400" >
                        <StackLayout  HorizontalOptions="Fill" >
                            <Frame  BackgroundColor="#375587" HeightRequest="20" BorderColor="#015198">
                                <Label  Text="Alert!" HorizontalTextAlignment="Start" VerticalTextAlignment="Center"
                                    FontSize="14.5" TextColor="White">
                                </Label>
                            </Frame>
                        </StackLayout>
                        <StackLayout Margin="10,30,10,10">
                            <Label x:Name="alertMessage" WidthRequest="380"  HeightRequest="100" TextColor="Black"  />
                        </StackLayout>

                        <StackLayout x:Name="alertOptions" HorizontalOptions="CenterAndExpand"  Orientation="Horizontal" Margin="10,20,20,20" >
                            <Button x:Name="yesOption" Text="YES" BorderRadius="6" BackgroundColor="ForestGreen" TextColor="White" HorizontalOptions="StartAndExpand" Clicked="confirm_Btn" ></Button>
                            <Button x:Name="noOption" Text="NO" BorderRadius="6" BackgroundColor="#375587" TextColor="White" HorizontalOptions="EndAndExpand" Clicked="cancel_Btn" ></Button>
                        </StackLayout>
                    </StackLayout>
                </StackLayout>
            </ContentView>
        </AbsoluteLayout>
    </ContentPage.Content>
</ContentPage>

Deallocating Memory of Dynamically Created Visual Objects /Elements

$
0
0

I am having real trouble figuring out how to release memory, I know you can run a GC.Collect(), and that this can run and is managed on it own in xamarin.. however..

My problem is how to let Xamarin know that something is allowed to be collected/ or freed or if possible remove it directly.

Consider a XAML page with this Root Element:

  <Grid x:Name="ContentGrid">
       </Grid>

At run time we dynamically add to the ContentGrid the following children (a ScrollView to ContengGrid and a Grid to the ScrollView)

ContentGrid ->ScrollView -> ScrollGrid

Then the ScrollGrid has has its columns dynamically added.. say in a little loop. say we add 12 columns of a certain fixed width

ContentGrid ->ScrollView -> ScrollGrid(with 12 fixed width columns)

As we create each column we add a image to the ScrollGrid

ContentGrid ->ScrollView -> ScrollGrid(with 12 fixed width columns and 1 image per column)

This renders as a nice little scrolling view of images and works. BUT I wish to know how to free up memory afterwards, because right now these things tend to live in the app seemingly forever..

Example 1 - We want to remove the 12 images and add a new set of images - How to remove / clear the 12 images and 12 columns from memory? - say the next set of images only has 3 images, so we want to get to 3 columns, and 3 images (having completely freed up the original 12)

Example 2 - We want to navigate away from this entirely (still keeping ContentGrid as the root), we wish to de-allocate all dynamically added content and get back to the state of an empty ContentGrid. (before presumably adding new controls to the ContentGrid for another purpose entirely)

Please try to answer the 2 example scenarios.

thanks.

--think I have answered my own question here...

Children.Remove(child) ...

How can I run a certain job in background even though after I close my app?

$
0
0

I am creating a mobile app for employee to check in. After check in, I want their location can be keep tracked all the time like 30 minutes interval. In the other words, every 30 minutes, the location of the mobile phone will be sent to the server through calling a WebService. It is impossible for me to ask them open the mobile app and screen all day long right? So I want to have a background process that will run inside the mobile phone? How can I achieve that? The concept is just like the alarm in the mobile phone, how it knows when to ring everyday even though the user does not open the alarm app? I have tried alarmManager but unfortunately nothing works. Thanks in advance.

How to get push notifications when app is foreground / when app is open?

$
0
0

Hello, I am working on xamarin forms, where I implemented push notification using google firebase and app center. And I am able to receive notifications when the app is closed and when the app is in the background but when it is foreground I am not able to receive How to handle the notification when the app is open / in the foreground.


How can i develop a compatible project which contains Android,Windows,Mac,iOS platforms?

$
0
0

In the first place i have created a blank Xamarin.Forms project on a Windows device, but i wanted to test it on a Mac desktop as well. When i tried to integrate a paid licence of Emgu Cv on this specific project, on the Mac desktop for both macOs and iOS platforms there was the following error:

System.BadImageFormatException: Method has no body
at Emgu.CV.Mat..ctor () [0x00000] in \bb\cv_pro\build\Emgu.CV\Core\Mat.cs:170

Afterwards, i created a Blank Forms App in my Mac device, having iOS and Android compatibility, and last but not least, i added inside the same solution, a Cocoa App in order to have macOs compatibility. When i integrated Emgu on this project, there was no error, and i successfully used the Emgu methods. So my question is: Is this an Emgu problem or a Xamarin.Forms one? Is there any importance in creating the project in Windows, and does the transfer to Mac create problems, or vice versa? Is there a best practice for developing a single compatible project which contains Android,Windows,Mac and i0S platforms?

Gmail content format is not proper when it is navigated from Xamarin forms application to gmail app

$
0
0

Hi,

I am working on xamarin forms application in which one of the screen , I am entering required details for Ex: Name, company etc,
and then clicking on submit button. After submitting the details will navigate to gmail which is available in the device.

As per my code the Expected result in gmail Content format will be as shown below.
**
Hi,

First Name: ABC
LastName: XYZ
Company: LMN

Thanks.**

But Result I am getting is

Hi,First Name: ABCLastName: XYZCompany: LMNThanks

This issue is only happening in Gmail. I have tested in yahoo and outlook account. It is working fine as expected

Please help me with this

How to add a Label to a Relative layout and center it horizontally

$
0
0

Hi all,

I'm trying to horizontally center a label in a Relative Layout.

My intuitive way of doing it would be to add the label to the layout with an X constraint equal to the parent's width minus the label's width, all divided by two.

However, the parent's width can be had. The Label's width equals -1.

RelativeLayout relativeLayout = new RelativeLayout();

            Label CenteredLabel = new Label ();
            CenteredLabel.Text = "Center this";
            CenteredLabel.XAlign = TextAlignment.Center;
            CenteredLabel.MinimumWidthRequest = relativeLayout.Width;
            relativeLayout.Children.Add 
                (CenteredLabel, Constraint.RelativeToParent ((parent)=>
                                                {return (parent.Width-CenteredLabel.Width)/2;}),
                  Constraint.Constant(0)
                );

Can anyone suggest why this is not working? Thanks!

Animation when changing MainPage of the application

$
0
0

I am using a MasterDetail template and I also have a login page. In my app when I am logged out I have set:

MainPage = new LoginPage();

When I will successfully log in I am just changing MainPage to MasterDetailNavigation like this:

MainPage = new MasterDetailNavigation();

However, there is no animation (page transition) when I am changing MainPage. How can I add it? It would be great to have i.e. the same animation which is when we are doing:

Navigation.PushAsync(new SomePage())

How can I achieve this animation?

Integrate FLIC-buttons to Xamarin.Forms

$
0
0

Hi lovely community,

I've got a small question. I bought a flic button from https://flic.io/ and I'd like to integrate it in my Xamarin.Forms project.

It works with Bluetooth and emits data to the smartphone when pressing or holding it. (Up/Down, DoubleClick and longpress events).

But https://flic.io/ doesn't offer any C# library that works with Xamarin.Forms. Only the SDK's for iOS and Android (native) are available and not made with the C# syntax.

So, now I'm staying here and I'm about to cry. I've been trying it with bluetooth scanning, and ended up finding the device with UUID and name but I couldn't create a connection to it, to read the data.

Can anyone explain or offer me any solution to work on this? I'm open to share the ready standalone code with the community for the next guys looking for it, because Flic-buttons (smartbuttons) are really nice!

P.S.: I'm working on an application to save a lot of lifes or injuries. So if anyone gives me the perfect solution, I will credit their name and website into this application, which may come out big very soon.

Thanks a lot! :-)

Viewing all 77050 articles
Browse latest View live


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