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

Tabbed Modal Page has no Toolbar and ToolbarItems? Bug?

$
0
0

I came across to a strange behavior today. When I push a tabbed page as navigationpage, code below works. I can see the toolbar items and tool bar.
But If I push same page as modal page without any single code, Below code doesnt work, I dont see any toolbar and toolbaritems.
Toolbar items work on a non-tabbed page so what is the deal with that? it is a bug in xamarin forms?

    <TabbedPage.ToolbarItems>
        <ToolbarItem  />
         <ToolbarItem  />
    </TabbedPage.ToolbarItems>

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?


Bug: Xamarin.Froms ControlTemplate with ToolbarItem does not work

$
0
0

Description
Hello.

Basic Setup: I want to have a Xamarin.Forms.ToolbarItem and a Xamarin.Forms.ControlTemplate in a ContentPage with a ViewModel. The ToolbarItem has a Command which should be executed on Tap.

Problem: The ToolbarItem.Command has a Binding to the ViewModel.Command which does not work.
When I start and click on the ToolbarItem it does not work.

Can someone tell me if I am missing something here, or if this is a real issue?
I am not very experienced with Bug reports so if I need to add/change something pleas tell me.

Steps to Reproduce
Create .net standard Project with Prism.Template
Choose Android Project for execution
Create a new Page with new Item Prism Content Page
Navigate at startup to that page
App.xaml.cs
await NavigationService.NavigateAsync("NavigationPage/DummyPage");
Insert the Code
DummTestPage

<?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="TestNetCore.Views.DummyPage">
    <ContentPage.ControlTemplate>
        <ControlTemplate>
            <StackLayout>
                <Grid>
                    <BoxView BackgroundColor="Lime" />
                    <Label>I TEST ControlTemplate</Label>
                </Grid>
                <ContentPresenter />
            </StackLayout>
        </ControlTemplate>
    </ContentPage.ControlTemplate>
    <ContentPage.ToolbarItems>
        <ToolbarItem Text="A" Clicked="MenuItem_OnClicked" Command="{Binding ToolbarTappedCommand}"></ToolbarItem>
    </ContentPage.ToolbarItems>
    <StackLayout>
        <Label FontSize="28">I AM AN EMPTY PAGE</Label>
    </StackLayout>
</ContentPage>

DummTestPage.cs

        public partial class DummyPage : ContentPage
    {
        #region Public Constructors

        public DummyPage()
        {
            InitializeComponent();
        }

        #endregion Public Constructors

        #region Private Methods

        private void MenuItem_OnClicked(object sender, EventArgs e)
        {
        }

        #endregion Private Methods
    }

DummyPageViewModel

public class DummyPageViewModel : BindableBase
    {
        #region Public Constructors

        public DummyPageViewModel()
        {
            ToolbarTappedCommand = new NewCommand();
        }

        #endregion Public Constructors

        #region Public Properties

        public ICommand ToolbarTappedCommand { get; set; }

        #endregion Public Properties
    }

    public class NewCommand : ICommand
    {
        #region Public Events

        public event EventHandler CanExecuteChanged;

        #endregion Public Events

        #region Public Methods

        public bool CanExecute(object parameter)
        {
            return true;
        }

        public void Execute(object parameter)
        {
        }

        #endregion Public Methods
    }

Set a Breakpoint to
NewCommand.CanExecute
NewCommand.Execute
MenuItem_OnClicked
Execute Programm

Expected Behavior
Execute NewCommand.CanExecute on startup
Execute NewCommand.Execute on Tap
Execute MenuItem_OnClicked on Tap

Actual Behavior
Execute MenuItem_OnClicked on Tap

Basic Information
Version with issue: Prism Template Pack 2.0.8 | Prism.Unit.Forms 7.0.0.362
Last known good version:
Xamarin.Forms version: 2.5.0.280555
IDE: VS17 15.6.1
Screenshots
Reproduction Link
What exactly do i need to do here?

Solutions
Removeing the lines in the XAML

xmlns:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms"
prism:ViewModelLocator.AutowireViewModel="True"

Every thing works as expected now
2. Removeing the ControlTemplate in the XMAL

    <ContentPage.ControlTemplate>
        <ControlTemplate>
            <StackLayout>
                <Grid>
                    <BoxView BackgroundColor="Lime" />
                    <Label>I TEST ControlTemplate</Label>
                </Grid>
                <ContentPresenter />
            </StackLayout>
        </ControlTemplate>
    </ContentPage.ControlTemplate>

Works but you dont have a controlTemplate now :(
3. Switching ControlTemplate and ToolbarItems

    <ContentPage.ToolbarItems>
        <ToolbarItem Text="A" Clicked="MenuItem_OnClicked" Command="{Binding ToolbarTappedCommand}"></ToolbarItem>
    </ContentPage.ToolbarItems>
    <ContentPage.ControlTemplate>
        <ControlTemplate>
            <StackLayout>
                <Grid>
                    <BoxView BackgroundColor="Lime" />
                    <Label>I TEST ControlTemplate</Label>
                </Grid>
                <ContentPresenter />
            </StackLayout>
        </ControlTemplate>
    </ContentPage.ControlTemplate>

CanExecute is not called at beginning
And if you set the ControlTemplate as StaticRessouce (which is what I like to do) this does not work
ControlTemplate="{StaticResource BaseControlTemplate}"

Tags
Xamarin.Froms ControlTemplate ToolbarItem Binding not working

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.

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?

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 ?

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

How can I add a style trigger to a RowDefiniton in xaml?

$
0
0

I have been trying to make my value of my row height update depending on if the device is portrait mode or not (set in the view model). I can't seem to find a way to add a trigger to a row definition to do this. Is there a way?

How to develop on Linux?

$
0
0

Hello,

I just installed MonoDevelop for Linux and I have no option for creating a Xamarin app project. I use Linux distribution Ubuntu and I would like to develop crossplatform mobile applications using Xamarin for Android and iOS.

I know that there is Rider by JetBrains, but it is not free, I just want to learn to code in Xamarin and make open source apps with no profit.


Adding image to StackLayout container failing if done using a local image from the .cs side

$
0
0

In my xaml file I am trying to set up a container that will house an unknown number of images, if I manually set an image inside there in the xaml file it works great:
<Image Source="Tamarin_portrait.JPG" WidthRequest="50" HeightRequest="50" Margin="10, 10, 10, 10"></Image>.

If I try to add a file from my cs side using an image online it works great:

var webImage = new Image { Source = ImageSource.FromUri(new Uri("https://xamarin.com/content/images/pages/forms/example-app.png")) }; imageContainer.Children.Add(webImage);

However if I try to add a local image to the imageContainer it fails to do so:
var locImage= new Image { Source = "Tamarin_portrait.JPG" }; //Or this way after declaring image without source-> locImage.Source = ImageSource.FromFile("Tamarin_portrait.JPG"); imageContainer.Children.Add(locImage);

I'm running it on android, and the image is located in the resources/drawable folder.

This feels like there's a simple mistake I'm making that I just don't see, can anyone shed some light on the problem?

Master Detail Page - Status Bar Problem on Android

$
0
0

I have a problem with the master detail page on Android. The drawer hides even the status bar. You can see only the icons...
I would like to have a semi transparent status bar. I have exactly the same code as in the docs.

How it looks like

What I would like to achieve

How Disable Gestures (swipe l/r) of CarouselPage?

$
0
0

Hi all,

I want to use CarouselPage to have the right-to-left transition animation for page content and the header is static.
Could you please give me a solution with Xamarin form? I can't find out any ways.

Thanks.

Platform specific XAML in Content Page

$
0
0

I am working on a toolbar for my app and hoping to use it in a cross platform manner. To do this I would like to be able to use a platform specific tag inside of my page content for that platform. To do this I would like to use a nice tag from the UWP, FontIcon, to set the icon for an item when using a uwp platform. I know this XAML doesn't work, but in essence what I want to do is the following "In Concept" to set the icon of a menu item command to be a glyph font icon on UWP and just use a file image source on the other platforms for now. How would I go about doing this in reality? I am not sure what the first step is.

<ContentPage.ToolbarItems>
        <ToolbarItem Name="MenuItem2" Order="Primary" Text="Add" Priority="0" Command="{Binding AddItemCommand}" >
            <ToolbarItem.Icon>
                    <On Platform="UWP">
                <FontIcon Glyph="&#xEB52;" FontFamily="Segoe MDL2 Assets" />
                </On>
                   <OnPlatform x:TypeArguments="FileImageSource" iOS="plus.png">
            </ToolbarItem.Icon>
        </ToolbarItem>
    </ContentPage.ToolbarItems>

Storing a push notifications

$
0
0

Xamarin forms or Xamarin android , how to store push notification on local database (Akavache) that notifications push from Microsoft AppCenter and displaying later for future use . Thank you Developers.

Viewing all 58056 articles
Browse latest View live


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