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

ScrollDownTo using text instead of marked

$
0
0

I'm trying to attach an automationId to items within a listview. Ideally by binding a project name to the item that is shown.

            <ListView
            ItemsSource="{Binding Projects}"
            AutomationId="{Binding Projects}
            HasUnevenRows="True"
            IsPullToRefreshEnabled="true"
            CachingStrategy="RecycleElement"
            HorizontalOptions="FillAndExpand"
            VerticalOptions="FillAndExpand">

The code is deploying but not running when I get to the page, has anyone found a good workaround to bind the ID like that?

Long term, I want to use it with the Xamarin Forms ability to scroll which can scroll to a marked item, but not scroll to a displayed text. If there is a way to scroll to a text displayed, that would be helpful but not something I've found documentation on yet.


Android Tablet SplitOnLandscape bug when changing back and forth from orientation.

$
0
0

Hey all,

When I am changing the orientation from landscape to portrait and back the MasterView of my MasterDetail view starts to overlap the DetailView. This seems odd behavior and it only happens on Tablets.

I have made two screenshots that can be found here: imgur.com/a/yw8vq.

Does anyone know a fix? Or do I need to report this?

Cheers,

Luuk

UI slow to fade on button click

$
0
0

Wondering if anyone has any explanation or advice here. I have a button click event where I want to set the screen to Opacity 0.2 so that it indicates to user that button has been pressed (as on some devices it takes a while to render a new page). I've spent some time looking at page render but this post is purely about the fade. Basically I am calling the fade action asynchronously on the page, I have also tried just setting the Opacity. SOMETIMES the screen fades instantly as I press the button, but often there is a 2 or 3 second delay, especially on our cheap devices, giving impression button hasnt been pressed. Is there something I am doing wrong here, I thought the UI thread would update straight away? Any help appreciated

So I bind button click to this command in view model

    private void OpenNewOrder(OutletInfo selectedOutlet, int incompleteSupplierOrderId)
    {
        var pageParams = new NewOrdersPageParameters();
        PopulateNewOrdersParams(pageParams, selectedOutlet, incompleteSupplierOrderId);

        // Fade the page to indicate to user that button has been pressed
        FadeThisPage().ContinueWith((task) =>
        {
            // Open up next screen
            LoadPage<NewOrdersCarouselViewModel>(pageParams);
        });
    }



/// <summary>
    /// Fades the page - needs to run asynchronously
    /// </summary>
    /// <returns></returns>
    private async Task FadeThisPage()
    {
        await Task.Run(() =>
        {
            Device.BeginInvokeOnMainThread(() =>
            {
                if (FadePageAction != null)
                {
                    FadePageAction.Invoke();
                }
            });
        });
    }

And the action itself in the View (Page code)

            viewModel.FadePageAction += () =>
            {
                // Fade the page

                Opacity = 0.2;
                //this.FadeTo(0.2, 1);
            };

Thanks

Page Lifecycle events - Loading a listview after page load

$
0
0

Hi, I have done a bit of googling and cant find any other page lifecycle events apart from OnAppearing and OnDisappearing, are there any others at the moment?

My listview is slow to load, so what I want to do is load the page, and then load the listview asynchronously. I have put the listview load in the OnAppearing at the moment, but the page does not load until the listview does, probably because it is on UI thread. But is there way of forcing UI to update, or another way of approaching this?

Thanks

[PRISM] Why my button is enable whereas my command should be false!

$
0
0

Hello,

I only want that my update button is active if entries are edited AND it's not the first load.
When i go on my page, data is loaded in entries and IsEdited switch to True, result my update button is active.
I have try to switch IsEdited = False; after the data load but it's not work...
Come on @NMackay ! :smile:

Best regards

My XAML:

            <StackLayout Grid.Row="0" Margin="20, 0, 20, 20" >
                <Label Style="{DynamicResource FormLabel}" Text="Nom"/>
                <Entry Style="{DynamicResource FormEntry}" Text="{Binding Lastname}" Keyboard="Default"/>
                <Label Style="{DynamicResource FormLabel}" Text="Prénom"/>
                <Entry Style="{DynamicResource FormEntry}" Text="{Binding Firstname}" Keyboard="Default"/>
                <Label Style="{DynamicResource FormLabel}" Text="Adresse électronique"/>
                <Entry Style="{DynamicResource FormEntry}" Text="{Binding Email}" Keyboard="Email"/>
                <Label Style="{DynamicResource FormLabel}" Text="Téléphone"/>
                <Entry Style="{DynamicResource FormEntry}" Text="{Binding Phone}" Keyboard="Telephone"/>
            </StackLayout>
            <StackLayout Grid.Row="1" Style="{DynamicResource BotActionBar}">
                <Button Style="{DynamicResource FormButton}" Text="Mettre à jour" Command="{Binding UpdateCommand}" HorizontalOptions="EndAndExpand"/>
            </StackLayout>

My ViewModel:

    public class ProfileEditViewModel : BindableBase
    {
        #region // Fields
        private bool _isUpdating;
        private bool _isEdited;
        private string _lastname;
        private string _firstname;
        private string _email;
        private string _phone;
        #endregion

        #region // Properties
        public INavigationService NavigationService { get; private set; }
        public DelegateCommand<string> NavigateCommand { get; private set; }
        public DelegateCommand UpdateCommand { get; private set; }

        public bool IsUpdating { get { return _isUpdating; } set { SetProperty(ref _isUpdating, value); } }
        public bool IsEdited { get { return _isEdited; } set { SetProperty(ref _isEdited, value); } }
        public string Lastname { get { return _lastname; } set { SetProperty(ref _lastname, value.NameFormat()); IsEdited = true; } }
        public string Firstname { get { return _firstname; } set { SetProperty(ref _firstname, value.NameFormat()); IsEdited = true; } }
        public string Email { get { return _email; } set { SetProperty(ref _email, value.ToLower()); IsEdited = true; } }
        public string Phone { get { return _phone; } set { SetProperty(ref _phone, value.PhoneFormat()); IsEdited = true; } }
        #endregion

        #region // Methods
        public ProfileEditViewModel(INavigationService navigationService)
        {
            NavigationService = navigationService;
            NavigateCommand = new DelegateCommand<string>(Navigate);
            UpdateCommand = new DelegateCommand(Update).ObservesCanExecute((p) => IsEdited);

            Lastname = App.API.User.Lastname;
            Firstname = App.API.User.Firstname;
            Email = App.API.User.Email;
            Phone = App.API.User.Phone;
            IsEdited = false;
        }

        private async void Update()
        {
            IsUpdating = true;
            if (await App.API.EditUserInfos(Lastname, Firstname, Email, Phone))
            {
                App.API.User.Lastname = Lastname;
                App.API.User.Firstname = Firstname;
                App.API.User.Email = Email;
                App.API.User.Phone = Phone;
                IsEdited = false;
            }
            IsUpdating = false;
        }

        private void Navigate(string s)
        {
            NavigationService.NavigateAsync(s);
        }
        #endregion
    }

Best regards

Checkbox - Xamarin Forms does not have even Checkboxes ?!

$
0
0

I am really frustrated now. I've begin a hard transition from Delphi to Xamarin, but finally it turns out that Xamarin Forms is some sort of void of controls.
There is some fragments written freely as open source but nothing seriously supported, and the worse of all - it lack basic controls like CheckBoxes , Radio Buttons and so on and on.
Is this correct or I am doing something wrong ?!

TreeView availability

$
0
0

We need a TreeView control for a customer's project - with the ability to display an icon for each node in the tree.

I've seen various discussions over the last year or two, and the only implementation seems to be:

https://github.com/danvanderboom/Xamarin-Forms-TreeView

or maybe something based on:

https://github.com/shuklajay/CollapseListView-in-xamarin.forms

Is anyone aware of any other solution? We're currently targeting only Android, so a custom renderer implementing a Xamarin.Android (i.e. Native) control is a possibility.

Using Xamarin.Auth just in the PCL Project

$
0
0

Hey,
is it possible to use Xamarin.Auth only in the Portable Project (= not using a CustomRenderer for the Login Page on each platform)?
I followed some guides but I didn't find the ultimate solution for this :D

Cheers!


XamlSamples.ListViewDemoPage //Xamarin.Forms.Xaml.ParseException

$
0
0

Hello!
I'm facing a problem I don't understand, I'm working on Xamarin on Mac and I'm doing the tutorials from official page, enjoying a lot until now, I'm on : https://developer.xamarin.com/guides/xamarin-forms/xaml/xaml-basics/data_binding_basics/
but when doing the ListViewDemoPage tutorial I always get this error:

Xamarin.Forms.Xaml.XamlParseException: Position 8:13. Type NamedColor not found in xmlns clr-namespace:XamlSamples;assembly=XamlSamples

I even downloaded a copy of this code from GitHub repository and I get the same error :-/

Please helpme to understand where is the problem, I updated nuggets, tried on IOS and Android... but cant find what's wrong ...

Thank so much for any help!!!

PD: English is not my mother language.

what is the best way of doing platform specific layout in XF?

$
0
0

So i have finished my android app and tried same app on uwp, layout looks awful. I need to start doing all these onplatform and idiom.device separation. where is the place for it? I went through this article https://developer.xamarin.com/guides/xamarin-forms/xaml/xaml-basics/xaml_markup_extensions/
it is quite informative indeed but my questions is there any advantage or disadvantage of using Static vs StaticResource markups. Static looks like caching into memory. does it cause any memory leak?

my master page overlap to upper status bar.

$
0
0

my master page overlap to upper status bar. how to overcome top space in master datail page

How do I install System.Net.Http on Xamarin Studio?

$
0
0

I have a project (PCL - Xamarin Forms) made in Visual Studio that runs on android and ios (build via Xamarin Mac Agent) correctly.
It uses System.Net.Http and ModernHttpClient

I have pulled the project on the mac and tried to compile it with Xamarin Studio but the reference to System.Net.Http is broken.
I have tried to install the package via nuget but I have this error:
Could not install package 'System.Net.Http 4.3.0'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.5,Profile=Profile259'

What is the right way to get the package correctly?

Navigation Stack Android Problem

$
0
0

Hi, i have same issues with the navigation stack because if navigate to more than two page in third page the GUI not update. For example a Editor not update its content while i write, but if i check if there was a content in it than i wrote, code result true. Or the webview content not update. If i use PopModalAsync it work correctly but with PopAsync no. What is the problem?

Thanks

Problems with the search bar cancel button

$
0
0

I have use Search bar in xaml (MVVM) in Xamarin.Forms.

My problem is that:
When device region and language change , automatically cancel button text is not changed. How I can change it. Please help me.

Thank You

Xamarin Studio for MAC / Visual Studio for MAC - Xamarin Forms SQLite Database

$
0
0

I am developing a cross platform (iOS / Android) app on a Mac OSX machine using Xamarin Studio. All of the Xamarin examples for local databases on mobile platforms reference SQLite and more specifically System.Data.Sqlite, etc. It seems that the Nuget Packages for SQLite are all Windows based. Does this mean that in order to develop this app, I need to develop on Windows ... but build on Mac of iOS?

I know that SQLite is maintained by its own team, but is this really a viable solution for a Mac OSX developer ecosystem? I did find this which isn't very promising:

https://gnuforensics.wordpress.com/2013/09/26/how-to-compile-sqlite-system-data-sqlite-on-linux-mono-using-xbuild/

What guidance do you have to develop iOS / Android mobile apps that will require a local database if using MAC OSX as the development environment?


Why Shared Projects?

$
0
0

Maybe I am missing something wonderful about them but every example I see from Xamarin Forms is using a Shared Project. I have never found a solid reason to use a shared project, putting compiler directives through the code for each platform just seems like it will lead to hard to maintain code.

PCL's have been really easy and great for containing code. To me shared projects have no purpose other than really quick demo code but even still PCL's work with a little bit of DI doesn't make things particularly complex, especially with XF's inbuilt Dependency Service.

The question is, why does anyone use these project types, why does Xamarin keep building examples in them, which means all newcomers to XF start to use them? I honestly have never seen a reason in XF to use a shared project.

But I am ready to have my eyes opened in case I missed something with Shared Projects.

SQLite.net NullReferenceException whilst following provided Xamarin example(s)

$
0
0

Hey guys,

Me again, with a different question about a different subject; SQLite.

I've got quite good skills in scripting SQL queries, but I'm struggling to connect my XamarinForms (Portable) solution to a local database.

I've followed the guide provided by Xamarin and their example on Github.

However, as mentioned I'm having some issues with connecting my already created solution with the database. Debugging my solution gives me nothing except an error message:

System.NullReferenceException: Object reference not set to an instance of an object.

in my for loop (looping through every object in a list of objects ):

foreach (Foundation found in result)
                {
                    await App.Database.SaveItemAsync(found);
                    count++;
                    Debug.WriteLine(count.ToString());
                }

result is the resulting set (List) from a call to a RESTful Api that most assuredly is NOT null, and is invoked after the result has been assigned to.

The reference to App.Dabatase.SaveItemAsync() is linked similar to the provided github example mentioned above.

Here is a linkto my project on Github. For the full source code, please see the referred Github link provided in previous sentence as it would be too much to write it all here.

The relevant files are App.cs, Data -> FoundationsDatabase.cs and GetFoundationsPage.cs

What are these files my solution keeps producing and how do i make them stop?

$
0
0

It seems everytime my solution is built, xamarin forms creates a file but does not overwrite the file when a new build has been made and its taking up lots of storage space. Not sure where there located but here is a screen shot from my disk utility

Title and Back-button text behaving differently iOS vs Android

$
0
0

Hi.
Been doing XF mostly via XAML for a few months now, and have come across a tricky issue.
Screens whose titles and back-button texts behave entirely as expected on iOS are wrong on Android. We've built the app for iOS at first, and are just at the stage of testing on Android to see what is working and what is not.
On Android, the title of the screen appears as the back-button text and the back-button text is nowhere to be seen.
See example screenshots of the relevant parts of the iOS and android screens in one part of the app.

iOS

Android

This is happening throughout the entire app.

What could be causing Android to get confused in this way? Anyone seen this before and fixed it?
Am I just fundamentally misunderstanding something about Android (I am far more familiar with iOS).
Any pointers would be helpful.

Thanks,
Alex

Set default value in label if value is 0

$
0
0

I have been spending way too much time on something that I thought would be simple. If the label text value shows "0", I want to display "N/D" instead. I have tried the following with no success. Weight is a double field in my ViewModel.

        <Label
        Grid.Row="2"
        Grid.Column="1"
        Text="{Binding Weight}">
                <Label.Triggers>
                        <DataTrigger TargetType="Label" Binding="{Binding Weight, Converter={StaticResource IsZeroConverter}}" Value="True">
                            <Setter Property="Text" Value="N/D"/>
                        </DataTrigger>
                </Label.Triggers>
       </Label>

The converter is below:

public class IsZeroConverter : IValueConverter
{
public IsZeroConverter()
{
}

    #region IValueConverter implementation

    public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
  return (int)value == 0;
    }

    public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        throw new NotImplementedException();
    }

    #endregion
}

}

Viewing all 91519 articles
Browse latest View live


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