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

Smooth scroll to position when ListView SelectedItem changed

$
0
0

Summary

Automatically scroll the ListView to the selected position when SelectedItem property is changed.
Works on iOS, but not implemented on Android or UWP.

API Changes

Update ListView renderers for Android and UWP.
We have already built this functionality using custom renderers. If approved, can create a PR.

Intended Use Case

Unify the UI behaviour across all three platforms.


how to off nestedscrolling in listview inside scrollview in xamarin forms

$
0
0



<ListView
x:Name="pasengerlist"
SelectionMode="None"
VerticalOptions="FillAndExpand"

                    BackgroundColor="White"
                    HasUnevenRows="true">
                    <ListView.ItemTemplate>
                        <DataTemplate>
                            <ViewCell
                                x:Name="            "
                                  >
                                <StackLayout
                                    Margin="5"
                                    Orientation="Vertical"
                                    VerticalOptions="FillAndExpand"
                                    HorizontalOptions="FillAndExpand">
                                    <Label
                                        Text="{Binding PaxNo}"
                                        TextColor="Red"
                                        FontSize="Micro" />
                                    <StackLayout
                                        Margin="10"
                                        Orientation="Horizontal"

                                        VerticalOptions="CenterAndExpand">
                                        <StackLayout
                                            Orientation="Vertical"
                                            HorizontalOptions="StartAndExpand">
                                            <Label
                                                Text="FIRST NAME"
                                                TextColor="Gray"
                                                FontSize="Micro" />
                                            <Frame
                                                BackgroundColor="White"
                                                BorderColor="Gray"
                                                CornerRadius="0"
                                                Padding="0"
                                                HasShadow="false">
                                                <Label
                                                    x:Name="fromname"
                                                    Text="{Binding FirstName}"
                                                    BackgroundColor="Transparent"
                                                    Margin="5"
                                                    FontSize="Micro"
                                                    TextColor="Black" />
                                            </Frame>
                                        </StackLayout>
                                        <StackLayout
                                            Orientation="Vertical"
                                            HorizontalOptions="CenterAndExpand">
                                            <Label
                                                Text="LAST NAME"
                                                TextColor="Gray"
                                                FontSize="Micro" />
                                            <Frame
                                                BackgroundColor="White"
                                                BorderColor="Gray"
                                                HasShadow="false"
                                                Padding="0"
                                                CornerRadius="0">
                                                <Label
                                                    x:Name="lastname"
                                                    Text="{Binding LastName}"
                                                    BackgroundColor="Transparent"
                                                    Margin="5"
                                                    FontSize="Micro"
                                                    TextColor="Black" />
                                            </Frame>
                                        </StackLayout>
                                        <StackLayout
                                            Orientation="Vertical"
                                            HorizontalOptions="EndAndExpand">
                                            <Label
                                                Text="GENDER"
                                                TextColor="Gray"
                                                FontSize="Micro" />
                                            <Frame
                                                BackgroundColor="White"
                                                HasShadow="false"
                                                BorderColor="Gray"
                                                Padding="0"
                                                CornerRadius="0">
                                                <Label
                                                    Text="{Binding Gender}"
                                                    Margin="5"
                                                    TextColor="Black"
                                                    FontSize="Micro" />
                                            </Frame>
                                        </StackLayout>
                                    </StackLayout>

                                    <BoxView
                                        Color="Silver"
                                        HeightRequest="1"
                                        HorizontalOptions="FillAndExpand" />
                                    <!--// end -->
                                    <StackLayout
                                        Margin="10"
                                        Orientation="Horizontal"
                                        VerticalOptions="Center">
                                        <StackLayout
                                            Orientation="Vertical"
                                            HorizontalOptions="StartAndExpand">
                                            <Label
                                                Text="MEAL AMOUNT : "
                                                TextColor="Gray"
                                                FontSize="Micro" />
                                            <Frame
                                                BackgroundColor="White"
                                                IsVisible="{Binding additonalservicevisibility1}"
                                                BorderColor="Gray"
                                                HasShadow="false"
                                                Padding="0"
                                                CornerRadius="0">
                                                <Picker
                                                    x:Name="meals"
                                                    BackgroundColor="Transparent"
                                                    Title="Select Here"
                                                    SelectedIndexChanged="Handle_PickerChanged"
                                                    ItemsSource="{Binding AdditionalServiceSelect.MealValueLst}"
                                                    ItemDisplayBinding="{Binding MealServiceName}"
                                                    FontSize="Micro"
                                                    TextColor="Black">
                                                </Picker>
                                            </Frame>
                                            <Label
                                                IsVisible="{Binding additonalservicevisibility2}"
                                                Text="Meals not Available!"
                                                FontSize="Micro"
                                                TextColor="Black" />
                                        </StackLayout>

                                    </StackLayout>
                                    <StackLayout
                                        IsVisible="false"
                                        Orientation="Horizontal"
                                        HorizontalOptions="StartAndExpand">
                                        <Label
                                            x:Name="totalamountMB"
                                            Text="TOTAL AMOUNT : "
                                            TextColor="Black"
                                            FontSize="Small"
                                            FontAttributes="Bold"
                                            Margin="10,0,0,0" />
                                        <Label
                                            Text="{Binding TotalAmount}"
                                            TextColor="Black"
                                            FontSize="Small"
                                            FontAttributes="Bold"
                                            Margin="10,0,0,0" />
                                    </StackLayout>
                                    <BoxView
                                        Color="Silver"
                                        HeightRequest="1"
                                        HorizontalOptions="FillAndExpand" />
                                    <StackLayout
                                        Margin="10"
                                        Orientation="Horizontal"
                                        VerticalOptions="Center">
                                        <StackLayout
                                            Orientation="Vertical"
                                            HorizontalOptions="StartAndExpand">
                                            <Label
                                                Text="AIRLINE NAME"
                                                TextColor="Gray"
                                                FontSize="Micro" />
                                            <Frame
                                                BackgroundColor="White"
                                                HasShadow="false"
                                                BorderColor="Gray"
                                                CornerRadius="0"
                                                Padding="0">
                                                <Label
                                                    Text="{Binding Airname}"
                                                    BackgroundColor="Transparent"
                                                    Margin="5"
                                                    FontSize="Micro"
                                                    TextColor="Black" />
                                            </Frame>
                                        </StackLayout>
                                         <StackLayout
                                            IsVisible="true"
                                            Orientation="Vertical"
                                            HorizontalOptions="EndAndExpand">
                                            <Label
                                                Text="FREQUENT FLYER NO."
                                                TextColor="Gray"
                                                FontSize="Micro" />
                                            <Frame
                                                BackgroundColor="White"
                                                BorderColor="Gray"
                                                HasShadow="false"
                                                Padding="0"
                                                CornerRadius="0">
                                                <Label
                                                    BackgroundColor="Transparent"
                                                    FontSize="Micro"
                                                    Margin="5"
                                                    TextColor="Black" />
                                            </Frame>
                                        </StackLayout>
                                        <StackLayout
                                             VerticalOptions="Center"
                                            HorizontalOptions="EndAndExpand">
                                            <Label
                                                Text="Get Employee"
                                                IsVisible="{Binding GetPasssengerVisibility}"
                                                VerticalOptions="Center"
                                                TextColor="Green"
                                                FontAttributes="Bold"
                                                FontSize="Small"
                                                HorizontalOptions="EndAndExpand" />
                                            <Label.GestureRecognizers>
                                                <TapGestureRecognizer
                                                    Tapped="Ondetaillabeltapped"
                                                    NumberOfTapsRequired="1" />
                                            </Label.GestureRecognizers>
                                        </StackLayout>

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

                <Label
                    Margin="0,0,10,0"
                    x:Name="baggageAmount"
                    HorizontalOptions="EndAndExpand"
                    Text=" Baggage Amount : 0 "
                    TextColor="Black"
                    FontSize="Micro" />
                <Label
                    Margin="0,0,10,0"
                    x:Name="wholetotalamount"
                    HorizontalOptions="EndAndExpand"
                    Text="Total Amount : 0"
                    TextColor="Black"
                    FontSize="Micro" />
                </StackLayout>
        </ScrollView>

Expander

$
0
0

Is there a way to put and expander inside a ContentPage? I have a MasterDetailPage app and i would like to have sort of an expander; like the one used by gmail app where you specify multiple gmail accounts; then you can hit the expander and switch between accounts.

i have attached an example image

Thanks
Nick

Filter-able Picker/Lookup control

$
0
0

Hi Guys,

I am looking for some plug-in or snap on code (no custom renderers please)
For a functionality like shown below.

I tried implementing this with https://github.com/rotorgames/Rg.Plugins.Popup, with a ListView, however the binding does not work with the control template.

Can you guys please suggest any better option? (or even how to get this working - small POC, please).

Thanks,
N Baua

Get Version Number and Version Name from the Android Manifest in Xamarin MyForm.xmal.cs file?

$
0
0

Xamarin Forms Users,

Please help, with a questions about getting information about an app at run time, using Xamarin Forms, with C#, via Visual Studio Community 2019.

How can one...

Get Version Number and Version Name from the Android Manifest in Xamarin "MyForm.xaml.cs" file?

Please advise.

Thanks.

-- Mark Kamoski

using System;
using Xamarin;
using Xamarin.Forms;

namespace Consecration2019
{
    public partial class MainPage : ContentPage
    {
        public MainPage()
        {
            this.InitializeComponent();
        }

        private void PickStartDay_Clicked(object sender, EventArgs e)
        {
            Application.Current.MainPage = new StartPickerPage();
        }

        private void GetAppDetails_Clicked(object sender, EventArgs e)
        {
            string myVersionName = string.Empty;

            //I have tried this but "Context" does not exist.
            //
            //var myVersionName = Context.PackageManager.GetPackageInfo(Context.PackageName, 0).VersionName;

            //I have tried this but "Application" does not contain a definition for "Context" here.
            //
            //string myVersionName = Application.Context.ApplicationContext.PackageManager.GetPackageInfo(Application.Context.ApplicationContext.PackageName, 0).VersionName;

            this.DisplayAlert(title: "App Details", message: "Note myVersionName='" + myVersionName + "' here.", cancel: "Ok");
        }
    }
}

Cancel webview navigation event, e.Cancel = true not working.

How can I prevent labels from taking up all available horizontal space when word wrapping?

$
0
0

I have labels inside a grid and I want them to take up only the necessary space to fit the text. With short messages this works correctly, but with longer messages that text wrap the label fills the available space even though the way the words wrapped means that it doesn't need it.

My account isn't allowed to post direct links yet but here is a screenshot:
photos.google.com/share/AF1QipNDOK7HtPb3rLREC2dhufaKCA9CnSpIqk-rRJTSSKQa-XO9c8UzNbHxVEMpfKlMOQ/photo/AF1QipMVZVv3ciXt9xafg_cfkVU68Te9_iwamMrWB7A6?key=ZDdjTnRpQkZaeWRfcU0yOXljZGNsTEdDS3p3XzdB

As you can see, the pink label takes up only the necessary amount of space, while the aquamarine one expanded to fill the available space despite having a large area on the right that doesn't have any text in it.

I've tried searching for solutions with no luck. The only thread I found that even mentions this problem has two developers bickering about whether or not the one trying to help actually understands what the problem is, and a solution is never posted. Does anyone know how to fix this?

XAML:
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="90"/>
</Grid.ColumnDefinitions>
<Label BackgroundColor="Aquamarine"
HorizontalTextAlignment="Left"
HorizontalOptions="Start"
Grid.Row="0" Grid.Column="0">
Hippopotamus vocabulary accentuates educational imbalances. Gymnastic crocodilians abbreviate gratuitously enourmous nomenclature.
</Label>
<Label BackgroundColor="Pink"
HorizontalTextAlignment="Left"
HorizontalOptions="Start"
Grid.Row="1" Grid.Column="0"
Margin="0,0,90,0">
Short.
</Label>
<StackLayout Grid.Row="0" Grid.Column="1" BackgroundColor="Yellow" HorizontalOptions="FillAndExpand"></StackLayout>
<StackLayout Grid.Row="1" Grid.Column="1" BackgroundColor="Green" HorizontalOptions="FillAndExpand"></StackLayout>
</Grid>

Typed Text not visible (Random) on android devices

$
0
0

This is a wired issue that we are facing. The App is developed with Xamarin Forms (With latest stable version available as of now).

The issue is for android 4.4, 5 as well as 9. Things are working fine on 6,7 and 8.

The problem is when a user types on an entry field, the text is not visible

In android 9 it only happens for one entry field.

For example the user registration screen, which has 4 entry fields and a picker, things go wrong as follows
4.4 and 5 - No text shown at all for all four entry fields.
in android 9 - The 4th entry text not shown (all 4 entries are pretty much the same.) moving the 1st, 2nd or the 3rd to be the last entry has the same effect. meaning the newly moved one to the bottom will not show the typed text, the previously entry with the issue (which has now become the 3rd in the list, shows the text correctly)

Once observation is the cursor is not visible in the entry field. We are using a custom renderer, however using the "entry" instead of the custom one still has the same effect.

Thanks


Which event is fired when back button is pressed while keyboard is open in android?

$
0
0

Hi All,

OnBackButtonPressed() is not hitting when pressing back button while keyboard is open.

Need to unfocus the entry when keyboard hides usin back button.

Any help is appreciated.
Thanks

AutoSuggestBox ItemsSource from SQLite database

$
0
0

I've got stuck with this, and am very new to Xamatin Forms.
(I also posted this Friday but can find no trace of it???)

I'm wanting to use the AutoSuggestBox from dotMorten in my Xamarin Forms app.

I have the list of values in a SQLite table:

public class Streets
{
    [PrimaryKey]
    [MaxLength(255)]
    public String StreetName { get; set; }
}

I'm wanting to use this table as the ItemsSource for the AutoSuggestBox but, using the ToDo example have this code to get the data from the table:

public Task<List<Streets>> LookupStreetsAsync(String query)
{
    return lookups.Table<Streets>().Where(s => s.StreetName.StartsWith(query)).OrderBy(s => s.StreetName).ToListAsync();
}

However I cannot use this as the ItemsSource

private void StreetAutoSuggestBox_TextChanged(AutoSuggestBox sender, AutoSuggestBoxTextChangedEventArgs e)
{
    if (e.Reason == AutoSuggestionBoxTextChangeReason.UserInput)
    {
        String query = sender.Text.Trim();
        // only auto suggest if 3 or more characters
        if (query.Length > 2)
        {
            sender.ItemsSource = App.Lookups.LookupStreetsAsync(query);
        }
    }
}

I get an error at sender.ItemsSource:

Cannot implicitly convert type 'System.Threading.Tasks.Task<System.Collections.Generic.List<XamarinFirst.Streets>>' to 'System.Collections.IList'. An explicit conversion exists (are you missing a cast?)

I have tried casting it to an IList but nothing I find Googling works, just different errors.

How can I use my SQLite table as the ItemsSource?

Thanks,
Mike

Hamburger menu Xamarin.Forms (especially for Android + iOS).

$
0
0

Good day!
I'm sorry for disturbing you.
Im new in Xamarin Forms and im trying to build a app which has hamburger menu like this...
Sorry but can not add screenshots ((
I found this in the Internet, but this is not the case and I could not add it

How can I add this correctly, please can u something advise or help with this?
Thank you in advance!

CollectionView Grid Span

$
0
0

Hi,

I am having some issues with the CollectionView I am running Xamarin.Forms 4.00 pre-8 with the below XAML

 <CollectionView ItemsSource="{Binding Media, Mode=OneWay}" ItemSizingStrategy="MeasureAllItems">
                          <CollectionView.ItemsLayout>
                              <GridItemsLayout Orientation="Horizontal" Span="3"/>
                          </CollectionView.ItemsLayout>
                      <CollectionView.ItemTemplate>
                          <DataTemplate>
                            <Grid Padding="0">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="100" />
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="100" />
                                </Grid.RowDefinitions>
                                  <Image Aspect="AspectFill" Source="{Binding .} "/>
                            </Grid>    
                          </DataTemplate>
                      </CollectionView.ItemTemplate>
                  </CollectionView>

This is rendering the view as below

Why would this be? I thought the views should render as a Grid with 3 columns and 2 rows?

Thanks in advance.

VS2019 Error - This ABI is no longer supported.

$
0
0

Existing solution builds fine in VS2017.
Pulled it down from TFS to a new directory for testing in VS2019.
Everything builds including the java binding libraries and all projects.
Until it gets to the droid project that fails.

Doing all the standard things like clean, delete bin and obj and .vs directories to clear up the build problem don't help.

Anyone seen it or have a hint?

Modal Popup not showing Navigation Bar

$
0
0

Hi,

Referring to this thread:

https://forums.xamarin.com/discussion/comment/370580#Comment_370580

when I changed from:

Navigation.PushModalAsync(new NavigationPage(new Signin())
{
    BarBackgroundColor = Color.White,
    BarTextColor = Color.Black
});

to:

await Navigation.PushModalAsync(new Signin());

now the popup is not showing the title bar

How can I fix this please?

Thanks,
Jassim

How to pass data back to previous page in Xamarin Forms?

$
0
0

How do I pass selected Item of list view present in one page to the previous page in Xamarin. Forms?
Please Help


Unwanted Behavior of Master-Detail Menu/Hamburger button

$
0
0

Description

XF: 3.6.0.293080
Using the basic template for Master-Detail App with SplitOnLandscape MasterBehavior the menu/hamburger button does not work as expected. The button shows in the Landscape mode while it shouldn't and it gets hidden in the Portrait mode while we return back to the Detail page.

Steps to Reproduce

  1. Create a Master-Detail Forms app from the given templates.
  2. Add SplitOnLandscape as MasterBehavior.
  3. Launch the app in Portrait mode.
  4. At this point you should be able to see the Hamburger/Menu button clicking which should show the Menu/Master page.
  5. Change the orientation to Landscape which will hide the Hamburger/Menu button which is expected behavior.
  6. Now tap on any of the items on the Detail page which should take you to the item detail page. (at this point the orientation is still in Landscape)
  7. Now, change the orientation to Portrait mode and press back button.
  8. Now once you come back to the detail page you won't be able to see the Hamburger/Menu button in the navigation and the only way to show the drawer is to swift left-to-right.

Expected Behavior

The app should show the Hamburger/Menu button in the Navigation page in Portrait mode and should hide in Landscape.

Actual Behavior

The app looses the Hamburger/Menu button after coming back to the detail page while changing the device orientation while we drill down the Detail page item.

Basic Information

  • Version with issue: 3.6.0.293080
  • Last known good version:
  • IDE: Visual Studio Community (7.7.2 build 21)
  • iOS: 12.2

how to bind category in grid view.

$
0
0

Hi
I want to Bind category dynamically in 2 dimensional like
00 01 02
10 11 12
20 21 22

Please give some idea that I will achieve it.

Thanks

Xamarin Live Player vs Gorilla Player

$
0
0

Can someone tell me what is better at the current moment? Xamarin Live Player is official, but still in development. Gorilla player seems more stable. Did you test them both so you can tell me the differences?

Xamarin.Forms project advice seeking

$
0
0

The App
I am attempting to make an app must have a client facing app and a business facing app. I have decided to use a web api for data extraction etc. I want to know whether it is a good idea to:

  • build two different apps for this purpose
  • build one app and have both functionalities in there and redirect user (customer or business) based on a certain credentials
  • build one mobile app and make the business app a web app

Bit of background info..
I would like to here from you which one makes the most sense. In terms of functionality, the client app will simply uses google maps to show places on a map and allows customers to interact with the places. The business side (the places) enables the user of the business to essentially see which customers have interacted with their place.

Java.Lang.SecurityException: in Maps

$
0
0

Hi im new and want to try out a Map on a Content page. And i get only a error with Java.Lang.SecurityException:

<ContentPage.BindingContext>
    <viewModel:MapModel/>
</ContentPage.BindingContext>
<ContentPage.Content>
    <StackLayout>
        <maps:Map WidthRequest="320" HeightRequest="200"
              IsShowingUser="true"
              MapType="Hybrid"
              VerticalOptions="Start"
              HorizontalOptions="FillAndExpand"/>         
    </StackLayout>
</ContentPage.Content>

package="com.companyname.FirstApp" android:installLocation="auto">
        <uses-sdk android:minSdkVersion="21" android:targetSdkVersion="27" />
        <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
        <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
        <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
        <uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
        <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
        <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
        <uses-permission android:name="android.permission.INTERNET" />
        <application android:label="FirstAPP.Android">
            <meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="NOT_PUBLIC" />
        </application>

I have no idea what are the Problem. Can you Help me?

Viewing all 76418 articles
Browse latest View live


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