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

Search Bar in Xamarin.Forms Xaml

$
0
0

Hi there, so I've been trying to add a search bar to my xaml page. I started by making a new project > Cross Platform > Mobile App (Xamarin.Forms) and then selecting Shared Project.

        <ContentPage.Content>
            <StackLayout>
                <Label Text="Find your item..."
                    VerticalOptions="StartAndExpand" 
                    HorizontalOptions="CenterAndExpand"
                    TextColor="#000000"
                    FontSize="18"
                    Margin="0,40,0,0"/>
            </StackLayout>
            <SearchBar/>
        </ContentPage.Content>

When doing this, it just says in the Xamarin.Forms.Previewer "An Exception occured while rendering the control." I've tried making different projects, nothing. I'm sure I've made it right, but I can't see what the problem is. Any ideas?


ListView not binding in Prism 7

$
0
0

Below I am showing my xaml file with a ListView control and my ViewModel... I am trying to binding some items to the ListView, but nothing happens.

I am using Prism 7 as my MVVM framework.

This is my xaml with a listview:

<?xml version="1.0" encoding="utf-8" ?>


































































    <!-- MY LISTVIEW. THE BINDING VALUES ARE CORRECT AND ARE PROPERTIES FROM LANCAMENTO CLASS -->

**
<ListView.ItemTemplate>










</ListView.ItemTemplate>
**

        </StackLayout>
    </Frame>
</StackLayout>

This is my ViewModel:

public class ClosedIncomePageViewModel : ViewModelBase
{
    private LancamentosFatura _lancamentosFatura;
    private Fatura _fatura;

** //HERE IS MY COLLECTION USED AS A SOURCE IN MY LISTVIEW. IT IS PUBLIC, CAUSE IT IS AN ESSENCIAL CONFIGURATION !!!
public ObservableCollection LancamentosCollection { get; set; }**

    public Fatura Fatura
    {
        get { return _fatura; }
        set { SetProperty(ref _fatura, value); }
    }

    public LancamentosFatura LancamentosFatura
    {
        get { return _lancamentosFatura; }
        set { SetProperty(ref _lancamentosFatura, value); }
    }

    public ClosedIncomePageViewModel(INavigationService navigationService)
        : base(navigationService)
    {
        LancamentosFatura = new LancamentosFatura();
    }

    public override void OnNavigatedTo(NavigationParameters parameters)
    {
        if (parameters.ContainsKey("lancamentos_fatura"))
        {
            LancamentosFatura = (LancamentosFatura)parameters["lancamentos_fatura"];

            //Atribui apenas o segundo elemento da lista de faturas (equivalente a primeira fatura fechada)
            LancamentosFatura.FaturaVisualizada = LancamentosFatura.Faturas[1];

            //Obtem os lançamentos e carrega Listview
            ObterLancamentos();
        }
    }

    private async void ObterLancamentos()
    {
        try
        {
            //Carrega o Loading...
            using (UserDialogs.Instance.Loading("Carregando..."))
            {
                await Task.Run(() => ProcessarXML());
            }

            if (LancamentosFatura.Lancamentos != null)
            {
                if (LancamentosFatura.Status.Codigo == "0")
                {

** //HERE I AM BINDING THE LIST TO MY LISTVIEW
//THE LancamentosFatura.Lancamentos IS COMING WITH ITEMS, BUT THE LISTVIEW IS NOT BINDING THE ROWS
LancamentosCollection = new ObservableCollection(LancamentosFatura.Lancamentos);**

                    Toast("Lançamentos da fatura fechada recuperadas com sucesso", System.Drawing.Color.Green);
                }
                else
                {
                    Toast("Não foi possível recuperar os lançamentos da fatura fechada", System.Drawing.Color.Red);
                }
            }
            else
            {
                Toast("Não foram encontrados lançamentos para a fatura fechada", System.Drawing.Color.Orange);
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }

    private void ProcessarXML()
    {
    ...
    }
}

Here is my Lancamento class:

public class Lancamento : ModelBase
{
    public Lancamento(XmlElement element)
    {
        Data = GetTextValue(element, "dt_lancto");
        Descricao = GetTextValue(element, "desc_lancto");
        Valor = GetTextValue(element, "vl_lancto");
        Tipo = (GetTextValue(element, "tp_sinal") == "C" ? "Crédito" : "Débito");
    }

    public string Data { get; set; }
    public string Descricao { get; set; }
    public string Valor { get; set; }
    public string Tipo { get; set; }
}

Download a byte array of a file to mobile

$
0
0
I have converted my file to byte array and saved in database and how can i save that file to my local device

Change layout based on accessibility font scale

$
0
0

I have an app that uses a grid with multiple columns for display of information. With standard font sizes the grid works well but when the font size is scaled up it would look better to switch to a layout that displays the information in a single column.

Is there a way in Xamarin Forms to change the layout based on the what font scale is set on the device. I need a solution for Android and iOS.

Thanks!

Xamarin forms Plugin.MediaManager video not played from url due to ssl.

$
0
0

the error is ssl certificate ,so i add in main activity this code

System.Net.ServicePointManager.ServerCertificateValidationCallback +=
delegate (object sender, System.Security.Cryptography.X509Certificates.X509Certificate certificate,
System.Security.Cryptography.X509Certificates.X509Chain chain,
System.Net.Security.SslPolicyErrors sslPolicyErrors)
{
if (sslPolicyErrors == System.Net.Security.SslPolicyErrors.None)
return true;

// Do not allow this client to communicate with unauthenticated servers.
return false;

};

when i used any other link for video then video play but my server video still not play on android but now on IOS video play.

Visual Tree Helper

$
0
0

Hi,

Is there an equivalent of WPF's VisualTreeHelper? I need to loop through all the visual elements of a page.

Thank you

when to use OnAppearing or OnDisappearing ?

$
0
0

I recognized that i never use these 2 methos instead I use constructor and method where I do navigation if I want to manipulate something before page appears or disappears. What is the best use cases for these 2 methods in XF?

Multi line text in label

$
0
0

I need this type of view. Is it feasible?
Please Help.

Thanks in advance.


Tool Bar Title at center

$
0
0

Hello,

i am getting stuck into the toolbar title aliging. i want to make the toolbar title at center. I am using the master Details Page.
Every time i am getting the toolbar null.

var toolbar = FindViewById<Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);

var actionBar = ((Android.App.Activity)Context).ActionBar;

private static MainActivity _this;

    public static View RootFindViewById<T>(int id) where T : View
    {
        return _this.FindViewById<T>(id);
    }

    public MainActivity()
    {
        _this = this;
    }

i have used all of the above methods and properties but still getting toolbar null.

Please suggest.

App crashing when user opens it from background

$
0
0

In the android version, if the app is running, and the user backs out and opens another app, and them resumes my app, occasionally I get this error (I was only able to find out after integrating hockey app):

Java.Lang.IllegalStateException: Fragment does not have a view

Xamarin: 4.2.0.719
Xamarin.Android: 7.0.1.6
Xamarin.Forms (according to nuget): 2.3.1.114

Is this a bug, or something to do with my code? Also, it seems like it happens more frequently on certain phones than others. For instance, it happens frequently on my Huawei G9 phone, but I've never experienced it on my Samsung Galaxy S5.

Here is the full error from hockey app:

java.lang.IllegalStateException: Fragment does not have a view
    at android.support.v4.app.Fragment$1.onFindViewById(Fragment.java:1933)
    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1057)
    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1252)
    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1234)
    at android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:2046)
    at android.support.v4.app.Fragment.performActivityCreated(Fragment.java:1989)
    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1092)
    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1252)
    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1234)
    at android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:2046)
    at android.support.v4.app.FragmentController.dispatchActivityCreated(FragmentController.java:174)
    at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:598)
    at md5b60ffeb829f638581ab2bb9b1a7f4f3f.FormsAppCompatActivity.n_onStart(Native Method)
    at md5b60ffeb829f638581ab2bb9b1a7f4f3f.FormsAppCompatActivity.onStart(FormsAppCompatActivity.java:120)
    at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1241)
    at android.app.Activity.performStart(Activity.java:6392)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2442)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2539)
    at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:4162)
    at android.app.ActivityThread.access$1000(ActivityThread.java:168)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1384)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:150)
    at android.app.ActivityThread.main(ActivityThread.java:5665)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:799)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:689)
Xamarin caused by: Java.Lang.IllegalStateException: Fragment does not have a view
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <368820a9888f43ddb85d18e87189adbf>:0 
  at Java.Interop.JniEnvironment+InstanceMethods.CallNonvirtualVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x000a7] in <a043032cf94a485190047a14918b9f60>:0 
  at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00066] in <a043032cf94a485190047a14918b9f60>:0 
  at Android.App.Activity.OnStart () [0x0000a] in <206240d88f7f44d795aacbc1d5348a1f>:0 
  at Xamarin.Forms.Platform.Android.FormsAppCompatActivity.OnStart () [0x00000] in <e3d80a9502b84521b638fbb10cce4a8a>:0 
  at Android.App.Activity.n_OnStart (System.IntPtr jnienv, System.IntPtr native__this) [0x00009] in <206240d88f7f44d795aacbc1d5348a1f>:0 
  at (wrapper dynamic-method) System.Object:aa5e8dd2-e3b8-418d-bea6-1b72ac744ccf (intptr,intptr)
  --- End of managed Java.Lang.IllegalStateException stack trace ---
java.lang.IllegalStateException: Fragment does not have a view
    at android.support.v4.app.Fragment$1.onFindViewById(Fragment.java:1933)
    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1057)
    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1252)
    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1234)
    at android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:2046)
    at android.support.v4.app.Fragment.performActivityCreated(Fragment.java:1989)
    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1092)
    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1252)
    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1234)
    at android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:2046)
    at android.support.v4.app.FragmentController.dispatchActivityCreated(FragmentController.java:174)
    at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:598)
    at md5b60ffeb829f638581ab2bb9b1a7f4f3f.FormsAppCompatActivity.n_onStart(Native Method)
    at md5b60ffeb829f638581ab2bb9b1a7f4f3f.FormsAppCompatActivity.onStart(FormsAppCompatActivity.java:120)
    at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1241)
    at android.app.Activity.performStart(Activity.java:6392)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2442)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2539)
    at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:4162)
    at android.app.ActivityThread.access$1000(ActivityThread.java:168)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1384)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:150)
    at android.app.ActivityThread.main(ActivityThread.java:5665)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:799)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:689)

Microsoft Identity Client Error "An error occurred while sending the request"

$
0
0

Hello,
I want to make Azure AD B2C with theirs module Microsoft.Indetity.Client. But when I try to implement their sample. After I go through this line
" AuthenticationResult ar = await App.PCA.AcquireTokenAsync(App.Scopes, GetUserByPolicy(App.PCA.Users, App.PolicySignUpSignIn), App.UiParent);"
after a few seconds, I get the following error: "An error occurred while sending the request". What is wrong here? Does anyone have a clue?

Firing method in the View when a property in the ViewModel changes

$
0
0
Hi all,
As the title says I would like to call a method in my View when a property in my ViewModel changes. I was wondering if this is possible to do it by using the INotifyPropertyChanged interface or if I should implement the observer - observable pattern on my own for this particular task.

Practical example: I have a StackLayout in the View and an integer property called number in the ViewModel, I want to call a method in the View which makes sure there are exactly n (where n is the value of number) entries in the StackLayout every time number changes.

Note: number is the output of a calculation in the model and it doesn't have to appear anywhere in the view.

Thanks to everyone in advance.

TargetFrameworkVersion I need V7.1 not v8

$
0
0

Hello

I am beginner Xamarin but I practice C # windowsforms for years

I installed only what connects Android 7.1 but I get this error

The $(TargetFrameworkVersion) for FormsViewGroup.dll (vv8.0) is greater than the $(TargetFrameworkVersion) for your project (v7.1). You need to increase the $(TargetFrameworkVersion) for your project.

The version 8 does not interest me I wish the version 7.1 as well on the emulator as on live player

My problem is that I can not find a trace of the v8 in the configuration of my project

How can I configure my project on version 7.1?

thanks in advance

Dependecy service get interface

$
0
0

I´m using cross platform project and i need to delegate a specific code for teh android project and i create an interface

namespace SilenceTv1._0
{
public interface ISoundPlayer
{

    void Play();
}

}

and in a Button_Clicked event do this line but send me an error
DependencyService.Get().Play();

throws "System.MissingMethodException: Default constructor not found for type SilenceTv1._0.ISoundPlayer"

SilenceTv1._0.ISoundPlayer its a interface dont have constructor right?

ios xamarin live player

$
0
0

how to connect my app with a database ?


CarouselView / CarouselPage has"freeze/lag" when i switch view/page

$
0
0

Hello,

I'm trying to understand how works the switch of view and the switch of pages from Carousel because when i switch view / page i have random "freeze/lags". When i switch page/view, what my app do? Reload binding? Resize layout and more?

Best regards

xamarin forms video and image capture plugin

$
0
0

I need a plugin in xamarin forms to take photos and videos. Other than xam.media.plugin ?

MessagingCenter not working

$
0
0

I had this Android App working. Then I started working on another branch, and today I continued on the Android App.
But it is no longer working. Reason is the MessagingCenter no longer works.
I have this at one location:

        MessagingCenter.Subscribe<App, FCM.NETStandard.Models.Message>(App.Current, "Hi", async (sender, arg) =>
        {
            await MessageReceived(arg);
        });

And at another location I have

        MessagingCenter.Send<object, FCM.NETStandard.Models.Message>(this, "Hi", msg);

And I can see that the subscription is made, but when the send happens, the subscribed delegate is not executed (any longer).
Tried it with other messages and it just does not do anything. What could be the reason?

Thanks

Ben

How to create ssl certificate and how use ssl certificate in client side

$
0
0

Hi,

I am facing security issues, The application does not have certificate pinning for securing communication. please help me pinning the certificate

Thanks advance

create a view above the navigation & status Bar on Xamarin.Forms?

$
0
0

Hello World,

I tried to write a view on top of the screen with a RelativeLayout or ModalViews,
it wasn't working cause both doesn't include Navigation & Status Bar on their layout.

Do you know any implementation to displaying a view on top of all existed views?

Maybe I will have to create a blank view in natives environments, hope it will be possible to add it's content from PCL
Could you maybe guide me to start? Which class to extend in both environnement?

Thnaks by advance,

Viewing all 77050 articles
Browse latest View live


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