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

Get BindingContext of cell in a ListView

$
0
0

I'm converting a C# layout to XAML. The layout displays a list of Contacts that each have an Id, a PhoneNumber, and a Name property. I have a method CallContact that accepts a Contact as a parameter. It fires off when the user taps a phone image that is in each cell (they access a details page by tapping elsewhere in the cell) The method displays a prompt like "Would you like to call <Name>?", so it needs both the Name and the PhoneNumber properties of the Contact object.

Previously, I had a C# file for my ViewCell that looked like this

C# ViewCell

public class ContactCell : ViewCell
{
    public ContactCell()
    {
        var lblName = new Label{Font = Font.SystemFontOfSize(NamedSize.Medium)};
        lblName.SetBinding(Label.TextProperty, "Name");

        var phoneImage = new Image
        {
            Source = "Images/phone.png"
        };

        var phoneImageTgr = new TapGestureRecognizer();
        phoneImageTgr.Tapped += (s, e) =>
        {
            var contact = BindingContext as Contact;
            if (contact != null)
                CallContact(contact);
        };

        phoneImage.GestureRecognizers.Add(phoneImageTgr);

        View = new StackLayout
        {
            HorizontalOptions = LayoutOptions.FillAndExpand,
            Orientation = StackOrientation.Horizontal,
            Children = { phoneImage, lblName }
        };
    }

    private void CallContact(Contact contact)
    {
    }
}

So I referenced the BindingContext of the cell to get the specific Contact. Is there anyway for me, from XAML, to reference the current BindingContext of the cell and pass it as a CommandParameter?

XAML

<StackLayout>
    <ListView ItemsSource="{Binding Contacts}" SelectedItem="{Binding SelectedItem}">
        <ListView.ItemTemplate>
            <DataTemplate>
                <ViewCell>
                    <StackLayout Orientation="Horizontal">
                        <Image Source="Images/phone.png">
                            <Image.GestureRecognizers>
                                <TapGestureRecognizer Command="{Binding CallContactCommand}" />
                            </Image.GestureRecognizers>
                        </Image>
                        <Label Font="Medium" Text="{Binding Name}" />
                    </StackLayout>
                </ViewCell>
            </DataTemplate>
        </ListView.ItemTemplate>
    </ListView>
</StackLayout>

UWP: prevent all lowercase table section headers?

$
0
0

Hello,

in my UWP app all my table section headers are are lower case. Is there a way to prevent this? For german speaking users this is quite irritating.

Regards,
Dirk

Progress Bar and Async Methods

$
0
0

I'm still trying to get my head around async methods in general, not just for this example, but this is a good example to start with. I'm just trying to display an animated progress bar in code behind for a Xamarin Forms toolkit I'm making for myself.

    public class DFProgressBar : ContentPage
        {
            public DFProgressBar()
            {
                var MyH1 = new Label();
                MyH1.Text = "Heading 1";
                MyH1.Style = DFDataEntryStyles.LabelStyles.Heading1();

                var MyProgressBar = new ProgressBar();
                MyProgressBar.Progress = 0.2;

                await MyProgressBar.ProgressTo(0.8, 250, Easing.Linear);          // This doesn't work. "The 'await' operator can only be used within an async method.

                Debug.WriteLine("Animation Completed");

                // Accomodate iPhone status bar.
                this.Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5);

                var MyContent = new StackLayout();
                MyContent.Children.Add(MyH1);
                MyContent.Children.Add(MyProgressBar);
                this.Content = MyContent;
            }
        }

Can I Navigate to a new page from a background thread.

$
0
0

I tried using
Device.BeginInvokeOnMainThread(()=>Application.Current.MainPage.Navigation.PushAsync(new SomePage()));
But it just dies. The same call made directly under an event handler works just fine. The second I make it a background operation, it's not happy.

Using Xamarin Forms version 2.3.4.247 in Visual Studio for Mac on iPhone Simulator.

How to Create PDF In Xamarin.Forms?

$
0
0

How to Create PDF In Xamarin.Forms? And How to save pdf in folder for android.ios,windows?

Xamarin.Forms Feature Roadmap

$
0
0

This roadmap outlines our anticipated feature releases.

Are there things you don't see here that you feel strongly deserve a spot? Make your voice heard and open a proposal on the Xamarin.Forms Evolution forum.

Primary Focus

Quality is top of the list. This means stability and performance first and foremost. Xamarin.Forms has been swiftly adopted as a preferred tool for delivering production apps in addition to rapid prototypes. Our focus and priorities are to support the Xamarin.Forms community in those areas. In the release schedule below, we've highlighted how and where we are making those investments.

A Note About Bugs

As this thread is primarily about the feature roadmap, we anticipate the important question "what about ___ bug"?! Improving quality by addressing bugs is huge priority and ongoing focus for the team, in addition to improve our communication across the board.

Disclaimer

We cannot predict the future and how everything will shake out. Things will change. Timing may be adjusted due to priority changes, in pursuit of quality standards, or any number of other really good reasons that we will strive to proactively and openly communicate.

The Features Roadmap and Timeline

We expect to deliver several pre-releases and stable releases during each version series.

Version Series Estimated Release
2.3 Q2 2017
3.0 Q3 2017
3.1 Q4 2017

Est Q2 2017

Performance


Fast Renderers
Label, Image, and Button controls.

Startup Time Improvements
Improve the startup and initialization time for Xamarin.Forms apps.

Features


Xamarin.Forms for macOS Preview
Xamarin.Forms is coming to macOS, joining iOS, Android, Windows, and Tizen as target platforms for Xamarin.Forms.

Est Q3 2017

Performance


Bulk renderer creation
Optimize rendering performance on Android with bulk operations.

Cut down on GPU overdraw for Android
Try to avoid overdraw on Android where possible to improve performance.

Layout Compression
LayoutCompression allows multiple layers of Xamarin.Forms layouts to be packed into a single native one.

Fast Renderers for Android
Optimize view renderers to streamline view creation and improve performance. Complete all other UI controls.

Reduce native views created
Cut down on backing native views created for Xamarin.Forms, as noted by Miguel in #42948.

Single DLL
Ship Xamarin.Forms as a single DLL to improve startup performance and assist the linker.

OneTime Binding Mode
A mode to express that a binding only need fire once.

Visual State Manager
Provide a Visual State Manager at the Xamarin.Forms level for managing visual properties of elements across visual states. This will allow developers to control how elements appear when they are disabled, focused, etc.

XAMLC Improvements
Reduce/remove reflection.

Deprecation of WP8.0 and 8.1
This will impact startup time in particular.

Features


.NET Standard 2.0
Xamarin.Forms support.

CarouselView v1 Stable
Stability and performance improvements. See PR.

FlexLayout
Review the original Evolution Proposal. CSS and FlexLayout are now being treated separately.

CSS-Like Styling
Adding the ability to style applications with CSS. Review the original Evolution Proposal. CSS and FlexLayout are now being treated separately.

Xamarin.Forms Embedding
Embed Xamarin.Forms into a native Xamarin.iOS, Xamarin.Android, and UWP.

G18n support
Globalization support enhancements including RTL.

MenuPage
Alternative to the MasterDetail page, but rendered as a platform-specific menu that makes creating flyouts easy.

Popover Control
A transient view that appears over other content, can anchor to existing UI elements, and resize. Includes nested navigation support.

Xamarin.Forms for macOS
Xamarin.Forms is coming to macOS, joining iOS, Android, Windows, and Tizen as target platforms for Xamarin.Forms.

Xamarin.Forms for GTK#
Xamarin.Forms is coming to Linux.

Xamarin.Forms for WPF

Other

Renderer API Standardization
Make it easier to create custom renderers.

Est Q4 2017

To be determined.

Open Source Contributions

As noted above, the Xamarin.Forms Evolution forum is the place to start.

[Edited 5/18/2017]

How to maintain login/logout sessions in Xamarin.Forms?

$
0
0

Hi All,
I have a login screen which takes user email and password to check from (Web API+Database) if they are valid. On success, it takes user to another page (a user profile page) which has a logout button that simply removes current page from navigation stack and moves back to login screen.
1- I want to have a login/logout mechanism that if user is logged in, he must remain logged in as long as he uses the app, means in case of an E-Commerce app, if he logged in and is browsing products , he must remain logged in even when placing an order.App should be able to retrieve user personal info from login screen because user is logged in. And user must only be logged out when done intentionally by going to profile and clicking logout button. Please Help.
Thanks

how to use Sqlite in Shared project

$
0
0

hey
as i mentioned in the title
how to use Sqlite in Shared project
all what i have found is tutorials for PCL projects only
please help


ScrollView Onplatform

$
0
0
<ScrollView Grid.Row="1" HorizontalOptions="Center">
                <ScrollView.HorizontalOptions>
                    <OnPlatform x:TypeArguments="x:LayoutOptions">
                        <OnPlatform.Android>Fill</OnPlatform.Android>
                        <OnPlatform.iOS>Fill</OnPlatform.iOS>
                        <OnPlatform.WinPhone>Center</OnPlatform.WinPhone>
                    </OnPlatform>
                </ScrollView.HorizontalOptions>

why this code isn't work!!??
Please Help me :(

listview binding header

$
0
0

Hi,

I have a listview, What I want is to bind the first element of the my List

to the header,

how I can do that

Setting tint color of an Image

$
0
0

Is there a way to change the tint color of a Forms.Image programmatically? Both in Android and iOS. The source of the Image is a simple .png file with transparent layer.

I will welcome any other suggestions too.

Thanks in advance.

Master Detail Page Back Button

$
0
0

At first, I made my project using this site
And i can navigate ohter pages through master(hamburger menu)

This is my question.
If i tapped a row of datagrid at ClientPage, it will navigate to ClientDetailPage.
And i can return ClientPage by clicked Navigation Back Button, But!! Hambuger menu icon is disappeared...

//MainPage.xaml
public MainPage()
{
InitializeComponent();
IsPresented = false;
menuList = new List();

            var page1 = new MasterPageItem() { Title = "Client Management", Icon = "ic_import_contacts_black.png", TargetType = typeof(CleintManagementView) };
            var page2 = new MasterPageItem() { Title = "WOD Management", Icon = "", TargetType = typeof(WODManagementView) };
            var page3 = new MasterPageItem() { Title = "Statics", Icon = "", TargetType = typeof(Statics) };

            menuList.Add(page1);
            menuList.Add(page2);
            menuList.Add(page3);

            MenuList.ItemsSource = menuList;
            Detail = new NavigationPage((Page)Activator.CreateInstance(typeof(CleintManagementView)));
}
        #region MasterDetail MenuList Selected
        private void MenuList_ItemSelected(object sender, SelectedItemChangedEventArgs e)
        {
            var item = (MasterPageItem)e.SelectedItem;
            Detail = new NavigationPage((Page)Activator.CreateInstance(item.TargetType));
           IsPresented = false;
        }

//ClientPage
private void dataGrid_GridDoubleTapped(object sender, Syncfusion.SfDataGrid.XForms.GridDoubleTappedEventsArgs e)
{
var masterDetail = App.Current.MainPage as MasterDetailPage;
var nav = new NavigationPage();

            var nextPage = new ClientManagementDetailView();
            var selected = e.RowData as People;
            nextPage.BindingContext = selected;
            nextPage.PassContext();
            masterDetail.Detail.Navigation.PushAsync(nextPage);
        }

ClientPage

ClientPage->Double Tapped->ClientDetailPage

Hamburger menu is disappeared..

CarouselView With List Images

$
0
0

Hi, I m trying to build a CarouselView with a list of images, without saving them in the resources.
Im trying this but it doesn't work:

` CarouselViewControl imagensSlide = new CarouselViewControl
{
ItemsSource = listaImagens,
ItemTemplate = new DataTemplate(() =>
{

                var gridCell = new Grid();
                gridCell.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) });
                gridCell.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) });

                Image imagem = new Image();
                imagem.Aspect = Aspect.Fill;

                BindingContextChanged += (sender, e) =>
                {

                    imagem = (Image)this.BindingContext;

                };

                gridCell.Children.Add(imagem, 0, 0);
                Grid.SetRowSpan(imagem, 2);



                return imagem;

            }),

        };

`

empty space under tableview / vertical options not working

$
0
0
<?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="ContentPageLearning.Page3"
             Title="Insert">
    <ContentPage.ToolbarItems>
        <ToolbarItem x:Name="page3setting" Text="Delete" Order="Secondary" Clicked="page3setting_Clicked"/>
    </ContentPage.ToolbarItems>
    <ContentPage.Content>
        <ScrollView VerticalOptions="Start">
            <StackLayout Orientation="Vertical" VerticalOptions="Start">
                <TableView Intent="Data" VerticalOptions="Start">
                    <TableRoot>
                        <TableSection Title="Insert your phrase below">
                            <EntryCell Label="ID" Text="{Binding ID}" IsEnabled="False" HorizontalTextAlignment="Center"/>
                            <EntryCell Label="DateTime" Text="{Binding DateTime}" IsEnabled="False" HorizontalTextAlignment="Center"/>
                            <EntryCell Label="Keyword" Text="{Binding Keyword}"></EntryCell>
                            <EntryCell Label="Phrase" Text="{Binding Phrase}"></EntryCell>
                        </TableSection>
                    </TableRoot>
                </TableView>
                <Picker Title="Select a Language" x:Name="favouriteLangList" SelectedItem="{Binding Language}">
                    <Picker.Items>
                        <x:String>Chinese</x:String>
                        <x:String>English</x:String>
                        <x:String>Japanese</x:String>
                    </Picker.Items>
                </Picker>
                <Button Text="Save" BackgroundColor="Blue" TextColor="White" Clicked="SaveButton_Clicked" />
                <Button Text="Cancel" BackgroundColor="Red" WidthRequest="160" TextColor="White" Clicked="CancelButton_Clicked" />
            </StackLayout>
        </ScrollView>
    </ContentPage.Content>
</ContentPage>


Don't know why my picker and buttons are at the end of page even set all vertical options to "Start"...

Application Settings using Xamarin Forms // Best Practice?

$
0
0

Hello!

I would like to ask the community for some advice regarding the creation of a “Settings” view. The goal is to provide options to a user and store them as application settings.

I’m using Xamarin Forms and was hoping for a “generic” solution, using as much shared code as possible. I’m targeting Android and WinPhone primarily.

I studied these examples: the excellent “Step Counter” application (https://xamarin.com/prebuilt/step-counter) and http://www.qualtechsoftware.com/qualtechsoftware/2014/01/menus-menus-menus-android-with-xamarin/. I understand the technique they applied, but there not using Xamarin Forms.

My question: what is to be considered best practice for managing application settings when using Xamarin Forms (hence, trying to be as “generic” as possible)? Maybe a small app or link to an article demonstrating this?

Thank you all for your time!


Application Settings using Xamarin Forms // Best Practice?

$
0
0

Hello!

I would like to ask the community for some advice regarding the creation of a “Settings” view. The goal is to provide options to a user and store them as application settings.

I’m using Xamarin Forms and was hoping for a “generic” solution, using as much shared code as possible. I’m targeting Android and WinPhone primarily.

I studied these examples: the excellent “Step Counter” application (https://xamarin.com/prebuilt/step-counter) and http://www.qualtechsoftware.com/qualtechsoftware/2014/01/menus-menus-menus-android-with-xamarin/. I understand the technique they applied, but there not using Xamarin Forms.

My question: what is to be considered best practice for managing application settings when using Xamarin Forms (hence, trying to be as “generic” as possible)? Maybe a small app or link to an article demonstrating this?

Thank you all for your time!

Sporadic libsqlite3_xamarin crashes on Android

$
0
0

Hi,
according to Android vitals in Google Play Store, sporadic crashes around libsqlite3_xamarin.so occur on different devices, Android versions (5/6/7) and processor architectures (arm, arm64,...).
Such a report looks like this:

backtrace:
  native: pc 000000000001cb5c  /mnt/asec/com.myexample.app-1/lib/arm64/libsqlite3_xamarin.so
  native: pc 000000000001d9d4  /mnt/asec/com.myexample.app-1/lib/arm64/libsqlite3_xamarin.so
  native: pc 0000000000093710  /mnt/asec/com.myexample.app-1/lib/arm64/libsqlite3_xamarin.so
  native: pc 0000000000093c00  /mnt/asec/com.myexample.app-1/lib/arm64/libsqlite3_xamarin.so
  native: pc 00000000000388fc  <anonymous:0000007afc698000>

I have HockeyApp crash reporting included, but no such crash is reported there (stays at 0 crashes).
Session counts are alive, and it did record other crashes in the past, so HockeyApp is working.

I could not reproduce such a crash on my devices, for me the app is working on all Android versions (4.4.4 upwards).
So, it is NOT such a "DllNotFoundException" issue which comes up searching for "libsqlite3_xamarin" in the forums.
It works in general, but seems to be not 100% stable in the wild.

Any ideas or suggestions to track this issue down are appreciated!
Heli

Some version information:
Visual Studio Enterprise 2017
Xamarin.Forms 2.3.4.247 (Nuget)
HockeyApp.Xamarin 4.1.5 (Nuget)
Mono.Data.Sqlite 4.0.0.0
NO other Sqlite (or ORM) Nuget package like sqlite-net-pcl, as I just need some simple SQL queries.
Of course some more Nuget packages (Settings, Geolocation, ZXing, ModernHttpClient,...), but I don't expect them to be related to this.

Geofence - Xamarin Forms

Move a rect on an image with HandlePan

$
0
0

Hello,
I have a rectangle that I want to move on the image with HandlePan.
How to use Handlepan to move the rectangle only inside the image ?
Thank you,
Christophe

Creating event in Calendar issue

$
0
0

I have created an Xamarin Forms app targeting Android. When the user enters an input date and clicking on save button, then an event will be stored in phone's calendar. This functionality is working for some phones like honor, Motorola. But calendar event is not created for Asus and Lenovo. What might be the reason ?

I tried to insert event into calendar with the help on the below link
https://developer.android.com/guide/topics/providers/calendar-provider.html

Viewing all 89864 articles
Browse latest View live