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

Binding property changed not firing Xamarin.Forms + Prism

$
0
0

Hello everyone!

I'm trying to consume a REST API and update the Text property of some Entry views. But as soon as I get a JSON response and set some properties of my POCO class the view it's not updating.

Take a look in my code:

ViewModel:

namespace MyApp.ViewModels
{
    public class CompanyInfoPageViewModel : ViewModelBase //which inherits BindableBase
    {
        private APIClient _apiClient;

        public CompanyInfoPageViewModel(
            INavigationService navigationService,
            IPageDialogService pageDialogService,
            APIClient apiClient) : base(navigationService, pageDialogService)
        {
            _apiClient = apiClient;

            Company = new Company();
        }

        private Company company;
        public Company Company
        {
            get { return company; }
            set { SetProperty(ref company, value); }
        }

    //Fired on TextChanged of txtCEP Entry
        public async void FindCEP(string text)
        {
            var response = await _apiClient.GetAsync("cep/" + text);
            if (response.IsSuccessStatusCode)
            {
                var json = await response.ToJObjectAsync();
                var error = json.Value<string>("errors");
                if (error == null)
                {
                    var data = json["data"];
                    Company.Endereco = json["data"]["log_no_abrev"].ToString();
                    Company.Bairro = json["data"]["bairro"].ToString();
                    Company.Cidade = json["data"]["cidade"].ToString();

                    //And the view it's not updated ;(
                }
                else
                {
                    await PageDialogService.DisplayAlertAsync("Ops", error, "OK");
                }
            }
            else
            {
                //displays another message
            }
        }
    }

    public class Company
    {
        public string Endereco { get; set; }
        public string Bairro { get; set; }
        public string Cidade { get; set; }
        public string CEP { get; set; }
    }
}

XAML

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms"
             prism:ViewModelLocator.AutowireViewModel="True"
             x:Class="MyApp.Views.CompanyInfo"
             Title="Dados da empresa">
    <StackLayout HorizontalOptions="FillAndExpand" VerticalOptions="Center">
        <StackLayout HorizontalOptions="FillAndExpand" VerticalOptions="Center" Padding="0,20,0,0">
            <Label Text="Endereço" FontSize="Large"/>
            <Entry Text="{Binding Company.CEP}" Placeholder="CEP" x:Name="txtCEP" />

            <Entry Text="{Binding Company.Endereco, Mode=TwoWay }" Placeholder="Rua, Av..." HorizontalOptions="FillAndExpand"/>
            <Entry Text="{Binding Company.Bairro}" Placeholder="Bairro" />
            <Entry Text="{Binding Company.Cidade}" Placeholder="Cidade" HorizontalOptions="FillAndExpand"/>
        </StackLayout>

        <Button Command="{Binding SalvarCommand}" Text="Salvar" Style="{StaticResource buttonPrimary}"/>
    </StackLayout>
</ContentPage>

Am I doing something wrong?


1-2s delay on page navigation - after page .ctor and before OnAppearing

$
0
0

I'm experiencing a 1-2 second delay navigating to one of my pages:

1) The page's constructor runs.
2) Then there is the delay.
3) Then the page visually changes and some "changed"-Events fire from Elements on the page.
4) Then OnAppearing is called.

Here is a debug-log:

2015-11-12 21:36:01.781 lc02iOS[3497:1604017] Navigate PgDlb_Szenen GotoSceneCommand
[0:] Navigate PgDlb_Szenen GotoSceneCommand
[0:]
2015-11-12 21:36:01.910 lc02iOS[3497:1604017] Szene Nr. 1
[0:] Szene Nr. 1
[0:]
2015-11-12 21:36:02.135 lc02iOS[3497:1604017] Start assigning Picker-Lists <- This happens @ the end of the .ctor
[0:] Start assigning Picker-Lists
[0:]
2015-11-12 21:36:02.264 lc02iOS[3497:1604017] Done assigning Picker-Lists
[0:] Done assigning Picker-Lists
[0:]
2015-11-12 21:36:02.391 lc02iOS[3497:1604017] Szene_Edit::OnViewConstruction
[0:] Szene_Edit::OnViewConstruction
[0:]
2015-11-12 21:36:02.536 lc02iOS[3497:1604017] Szene_Edit::OnViewConstruction - done <- .ctor done - now the 1-2s delay, see times!
[0:] Szene_Edit::OnViewConstruction - done
[0:]
2015-11-12 21:36:04.248 lc02iOS[3497:1604017] LichtleistungChangedCommand 1 <- Events start firing
[0:] LichtleistungChangedCommand 1
[0:]
2015-11-12 21:36:04.329 lc02iOS[3497:1604017] LichtleistungChangedCommand 2
[0:] LichtleistungChangedCommand 2
[0:]
2015-11-12 21:36:04.467 lc02iOS[3497:1604017] CctDimChangedCommand 1
[0:] CctDimChangedCommand 1
[0:]
2015-11-12 21:36:04.597 lc02iOS[3497:1604017] CctDimChangedCommand 2
[0:] CctDimChangedCommand 2
[0:]
2015-11-12 21:36:04.731 lc02iOS[3497:1604017] OnAppearing1 <- OnAppearing
[0:] OnAppearing1
[0:]
2015-11-12 21:36:04.861 lc02iOS[3497:1604017] OnAppearing base
[0:] OnAppearing base
[0:]
2015-11-12 21:36:04.987 lc02iOS[3497:1604017] OnAppearing done
[0:] OnAppearing done

What could be causing this delay? What happens during this phase? The UX ist quite bad, as the user doesn't see the page change until ca. 2s after tapping an Icon.

Playing audio files in xamarin forms

$
0
0

Hi,
Can anyone tried to play audio files in the application using xamarin forms.If so please show me a way to implement this.

Thanks ,
sunil

FileInfo Bug?

$
0
0

Hi,

I just notice that FileInfo does not behave as expected on Android platform. It seems that:

  • LastAccessTime is actually CreationTime, since it does not change
  • LastWriteTime seems to be correct
  • And CreationTime seems to be updated each time file is updated.

Anyone else notice the same behavior?

Regards,
Novak

CachedImage FFImageLoading for Xamarin.Forms

$
0
0

https://github.com/molinch/FFImageLoading or https://github.com/daniel-luberda/FFImageLoading/ (new Forms features)

DEMO: https://github.com/daniel-luberda/FFImageLoading/tree/master/samples/ImageLoading.Forms.Sample

Caching support

The library automatically deduplicates similar requests: if 100 similar requests arrive at same time then one real loading will be performed while 99 others will wait. When the 1st real read is done then the 99 waiters will get the image.

Both a memory cache and a disk cache are present.

By default, on Android, images are loaded without transparency channel. This allows saving 50% of memory since 1 pixel uses 2 bytes instead of 4 bytes in RGBA (it can be changed).

WebP support

WebP is supported on both iOS and Android.

Downsampling

Downloaded images can be automatically downsampled to specified size (less memory usage). DownsampleHeight and DownsampleWidth properties

Retry

Downloads can be repeated if not succeeded: RetryCount and RetryDelay properties.

Placeholders support

  • LoadingPlaceholder

  • ErrorPlaceholder

image image

After this pull it'll also support Transformations!
https://github.com/molinch/FFImageLoading/pull/47

Transformations support

It doesn't modify original source images. Example:

  • RoundedTransformation

  • CircleTransformation

  • GrayscaleTransformation

image image

... and some more features. Feel free to test it. Not all features are on nuget yet (older version).

Difference between View, ViewModel, Model, Views, and Page?

$
0
0

Alright, I am having a very difficult time with understanding this process of MVVM.

This is what I know: (Expand if it helps)
View=Xaml, handles all of the UI features
ViewModel=C#, handles all the communication between UI and model C#
Model=C#, classes that hold data

Not so sure of:
Pages = Forms that show on devices?
Views = Types of Forms?

And my questions:
What is the difference between a Page, Form, and View?
Where do I build out the ViewModel if using forms? (As when creating a new form, I get XAML and XAML.cs, the XAML.cs already implements ContentPage, so where does INotifyPropertyChanged go? Seperate class?)
Does the PAGENAME.xaml.cs act as a ViewModel? Or what is that considered?
Are there specific folders for these? Currently I have Views(Forms; .xaml and .xaml.cs) and Models(data objects)

I already looked:
https://developer.xamarin.com/guides/xamarin-forms/xaml/xaml-basics/data_bindings_to_mvvm/
https://blog.xamarin.com/introduction-to-data-binding/
https://forums.xamarin.com/discussion/72861/simple-binding-in-xaml

But none really provide any detail outside what to do, not how or why.

Trying to accomplish:
Xamarin CrossPlatform App using Xaml forms and a PCL Library.

How to return back to application with Messaging Plugin

$
0
0

Hi All,

Once the user hit the send button available within using Xam Messaging Plugin, can we configure it so the user would return back to our application automatically?

-iKK

UWP not building latest version of code

$
0
0

There isn't a UWP sub-forum here yet, so I shall post this here for now...

Today is the first day I have noticed this issue. Today there was also a stable Xamarin update. May or may not be co-incidental.

At first I thought there were some XF features that weren't working in UWP (e.g. padding), but what I have noticed eventually is my UWP project is building an older version of my code (eventually it catches up on some of the changes I have made,but not necessarily all of them) - maybe there's a cache somewhere and it hasn't picked up changes yet? I did try cleaning the solution but that didn't change anything.

Anyone run into this and know how to fix it? I'm using latest (this morning!) version of Xamarin in VS2015 Community on 64-bit Windows 10 Pro with AU. I suspect this may be one which is hard to reproduce (given the intermittent nature of the error), but I guarantee this is what is happenning. :-(

P.S. this is deploying directly to my computer (which I have been enjoying as it runs so quickly, since no emulator needed).


Xam.Plugins.Notifier not working in android

$
0
0

I installed the nuget package, and it is working fine in UWP (both on phone and pc), but I never get any notifications on my android device. I've debugged, and the CrossLocalNotifications.Current.Show() method is being called, with no error, but I just never see the notification. Is there any permissions I am missing? Or could it be my device? (Huawei G9)

Playing sounds with Xamarin.Forms

$
0
0

Hi!

I am studying Xamarin, and, as a practice, trying to make a stopwatch which ticks every second, but I didn't found any informatin about working with sounds on forums. Where to find this information?

With best regards!

Cursor keys in listbox

$
0
0

Hello i am building an APP for a android TV box. I use a listview and want to use the remote control to scroll in the listview items to select them. I notices that the remote control works as a keyboard but for the buttons ii use in the app it works but in the listview i have no keyboard control.
I cannot scroll and select an item via the keyboard wich is connected via USB. Th keyboard works in all other apps.

What is a good library to use for MVVM with Xamarin Forms

$
0
0

Hi,

I am getting started on Xamarin and decided to use Xamarin Forms. What is the good MVVM library to use for Xamarin.Forms?

Xamarin.forms Frame OutlineColor doesn't work on Android

$
0
0

Hey,

I am trying to have a frame which has a border around it and by setting the OutlineColor is does show up on iOS+WP but it doesn't on Android. I have been googling alittle and the issue gets changed to resolved even though it still persists.

Does anyone know a quick fix, since I need this border to complete my project.

Sincerely,

Luuk

Can we place SearchBar in the navigation bar

$
0
0

Hi,

Can we place SearchBar in the navigation bar (like toolbar item)?

Thanks,
Aratrika

How can i show a different page if the list is empty?

$
0
0

So i was wondering if I could show a different page with a label and button if the listveiw is empty in xaml. Any ideas?Thanks in advance.


Navigation Page Android Problem

$
0
0

Hi, i have a problem with Navigation Page because it work correctly in 2 page, but if i go to the third page not update the GUI for example the input in the Editor is hide or the WebView looks empty but work. If i use the PopModalAsync work correctly but with PopAsync not work. someone can help me?

Zxing Scanner

$
0
0

I am using the ZXing.Net.Mobile for Forms
i Need the Change the Icon For Flash Button and I need to remove Text for it
How???

zxing scanner

$
0
0

I am Use Zxing for scanner the QR the Problem is Why the Button Text and Top Text is not show

Context menu custom renderer for ListView

$
0
0

I am developing and app using Xamarin.Forms. I am using ListView context actions to display context menu. I am adding icons for all the context actions. The icons only appear in Android. iOS app will only show text. I know that iOS does not support icons for context menu. Is there a way I can achieve this using custom renderers.

Emergency: Can't install Microsoft.Bcl.Build.1.0.14 in Visual Studio 2015 for Android project

$
0
0

I am trying to use "PortableRest" for my Xamarin Forms portable projects(IOS project can add PortableRest.3.0.1 fine).
I can't add package "PortableRest.3.0.1" to my Droid project, the following are the error message in output.

I tried on both OS X and Window Xamarin Studio,
Xamarin Studio OS X/Windows doesn't have problem to add "PortableRest.3.0.1" to Android project at all.

I followed an old post said that I need to reinstall Portable library, Xamarin Studio,reboot etc, no matter what I do,
Visual Studio can't add "PortableRest.3.0.1",

Please help, I have been stuck here for few hours already.

Thank you!

=======Output=======
Resolved actions to install package 'PortableRest.3.0.1'
Install failed. Rolling back...
Package 'Microsoft.Bcl.Build.1.0.14 : ' does not exist in project 'App1.Droid'
Package 'Microsoft.Bcl.Build.1.0.14 : ' does not exist in folder 'C:\Users\Dev\Documents\Projects\App1\packages'
Could not install package 'Microsoft.Bcl.Build 1.0.14'. You are trying to install this package into a project that targets 'MonoAndroid,Version=v6.0', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

=======Error=======
Error Could not install package 'Microsoft.Bcl.Build 1.0.14'. You are trying to install this package into a project that targets 'MonoAndroid,Version=v6.0', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author. 0

Viewing all 91519 articles
Browse latest View live


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