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

Using App Compat/App Compat theme breaks Navigation.RemovePage on Android

$
0
0

Issue:
I am using App Compat and the Theme.AppCompat.NoActionBar theme in my Xamarin.Forms Android project. I have a button that I want to go back to a certain page, so I am using Navigation.RemovePage to remove all pages except the page I want to go back to and the current page, and then I am using Navigation.PopAsync() to go back. This works normally on Android, but once I start using App Compat it just goes to a blank page that is whatever color I set as my windowBackground color. Anyone know how to fix this or if it is a bug?

Example Project:
https://drive.google.com/file/d/0B68aZqcn2sxXNG1FVl9ubzJvM2M/view?usp=sharing


MVVM

$
0
0

Hi,

I've been working with Xamarin.Forms for a while but I've not been using the MVVM pattern. I am trying to get an understanding now to keep up-to-date with industry standards.

I have built a small sample, and I'm wondering if what I've done below is acceptable for the MVVM pattern.

View:

 public class Landing : ContentPage
    {
        public Landing()
        {
            BindingContext = new LandingViewModel();
            Content = new Grid
            {
                RowDefinitions = {
                    new RowDefinition { Height = new GridLength(1, GridUnitType.Star)},
                    new RowDefinition { Height = new GridLength(1, GridUnitType.Star)},
                },
                ColumnDefinitions = {
                    new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star)},
                },
                Children = {
                    new Entry().Invoke(t=>t.TextChanged += FocusTextChangedEvent),
                    new BoxView { BackgroundColor = Color.White },
                    new Label { FontAttributes = FontAttributes.Bold, FontSize = 32, VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.Center }.Bind("ScannedShipmentNumber"),
                    new Button { Text = "Submit", BackgroundColor = Color.FromRgb(0, 73, 144), TextColor = Color.White, HeightRequest = 65, WidthRequest = 120, FontSize = 18, VerticalOptions = LayoutOptions.Center, Margin = new Thickness(15, 0, 15, 0) }.Row(1).Bind("SubmitButtonCommand")
                },
                RowSpacing = 0,
                ColumnSpacing = 0
            };
        }

        void FocusTextChangedEvent(object sender, TextChangedEventArgs e)
        {
            LandingViewModel vm = (LandingViewModel)BindingContext;
            vm.ScannedShipmentNumber = e.NewTextValue;
        }

        protected override void OnAppearing()
        {
            base.OnAppearing();
            Grid content = (Grid)Content;
            content.Children.FirstOrDefault(f => f.GetType() == typeof(Entry)).Focus();
        }
    }

ViewModel:

public class LandingViewModel : INotifyPropertyChanged
    {
        public ICommand SubmitButtonCommand => new Command(SubmitButtonClicked);

        private string _scannedShimentNumber = "...";

        void SubmitButtonClicked() {
            ScannedShipmentNumber = "Test";
        }

        public string ScannedShipmentNumber
        { 
            get { return _scannedShimentNumber; }
            set {
                _scannedShimentNumber = value;
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(ScannedShipmentNumber)));
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;
    }

Am I allowed to mix logic like taking advantage of the TextChanged event in the CS?

Thanks

Check the internet connectivity for the whole application.

$
0
0

How to check the internet connectivity of the xamarin forms application continuously? Can any one help me in doing this.

How can you translate OnPlateform in code behind ?

$
0
0

Hi there !

I have a simple question. How can I do the same thing here in code behind :

<Label x:Name="lbl">
        <Label.FontFamily>
            <OnPlatform x:TypeArguments="x:String">
                <On Platform="iOS" Value="OpenSans-Semibold"/>
                <On Platform="Android" Value="Volkhov-Italic.ttf#Volkhov-Italic"/>
            </OnPlatform>
        </Label.FontFamily>
</Label>

Thank you so much :smile:

UI Stops updating when navigating back to a page only on Android 5.1.1

$
0
0

For some reason when I leave a page and then navigate back to it. When I try to type in an Entry or select from a Picker, the value is not displayed on the UI. The keyboard still appears and I can see the text in the autocomplete but the UI remains blank.

This doesn't happen on Android 6.0

The page in question looks like this

    <Image x:Name="ImageUpload" Source="Upload"/>

    <Label x:Name="labelUpload" Text="" HorizontalOptions="Center"
        VerticalOptions="Center"/>

    <StackLayout Orientation="Vertical" Margin="20, 0, 20, 0">
        <ActivityIndicator x:Name="spinner" IsRunning="True" IsVisible="False"/>
        <ProgressBar x:Name="uploadProgress" IsVisible="False" Margin="30, 0, 30, 0" Progress="{Binding uploadProgress}"/>
        <Label HorizontalOptions="Center" x:Name="status"/>
    </StackLayout>

    <StackLayout Margin="20, 0,0,0" Orientation="Horizontal">
        <Label VerticalOptions="Center"  Text="Fail Reason"/>
        <Picker HorizontalOptions="FillAndExpand"  ItemsSource="{Binding Reasons}" x:Name="FailReason"></Picker>
    </StackLayout>
    <StackLayout Margin="20, 0,0,0" Orientation="Horizontal">
        <Label VerticalOptions="Center"  Text="Additional Comments"/>
        <Entry HorizontalOptions="FillAndExpand" x:Name="Comment" />
    </StackLayout>
    <Entry HorizontalOptions="FillAndExpand" x:Name="Comment" />


    <StackLayout Orientation="Horizontal" HorizontalOptions="Center">
        <Label VerticalOptions="Center" Text="Attach additional files"/>
        <Button Clicked="OpenFileExplorer" Text="Add"></Button>
    </StackLayout>

    <ListView x:Name="files" ItemsSource="{Binding files}">
        <ListView.ItemTemplate>
            <DataTemplate>
                <ViewCell>
                    <ViewCell.ContextActions>
                        <MenuItem Clicked="RemoveImage" CommandParameter="{Binding .}" Text="Delete"/>
                    </ViewCell.ContextActions>
                    <StackLayout Orientation="Horizontal">
                        <Image  Source="{Binding thumbnail}"></Image>
                        <Label Text="{Binding fileName}" FontSize="18"/>
                    </StackLayout>
                </ViewCell>
            </DataTemplate>
        </ListView.ItemTemplate>
    </ListView>
</StackLayout>

Running xamarin on a processor without hyper-threading

$
0
0

Hey there!

Here's the thing, a long time ago I tried to compile xamarin.forms (for android) and couldn't manage to run the emulator on my desktop pc. After some research, I figured out that it was due to my processor (FX8320e), which hadn't the capability to emulate the android. I could compile fine on my notebook and run the Android emulator, which has i7 (and hyper-threading). At that time I thought the issue was only the lack of hyper-threading, so I kept developing on my notebook since then.

But I really wish I could run it on my desktop pc. I researched a bit more and noticed that it's not exactly hyper-threading the issue, but the lack of Hyper-V. Can I manage to run that on a FX8320e? If anyone could help me out with this, since I'm not that pro on hardware stuff, I would really appreciate!

Thanks in advance

Extended char (diameter sign) is displayed with a "box" before in Android

$
0
0

Hello,
I want to display a list of circumferences values in a Picker. Elements are displayed correctly on UWP and iOS, but on Android, the "diameter char" is displayed with a box before:

… and no "box" in UWP:

Here is the code I use in order to generate strings containing the circumference value followed by its corresponding diameter between brackets:

public static string GetIntToCircumferenceString(int p_nValue)
{
StringBuilder l_sbResult = new StringBuilder();
l_sbResult.Append(p_nValue);
if (p_nValue >= (int)Math.PI)
{
int l_nDiameter = Convert.ToInt32((double)p_nValue / Math.PI);
l_sbResult.AppendFormat(" (\u00F8{0})", l_nDiameter);
}
return (l_sbResult.ToString());
}

I already tried to replace "\u00F8" by "U\000000F8" but it did not work

Thank you in advance for your help

Greetings

J-D Gasser

Data Binding In Grid View With Multiple Image Picker

$
0
0

Hi all,
I am uploaded multiple image with EClImagePicker but It Display Only First Image In My GridView.Cell In Rest Of My Cell. Is there any way to solve this type of error It helps me a lot.
I am getting source of all files with counter.

Thanks in advance.


App crashes on certain events

$
0
0

Hi guys,

I've written an app with a multi-page form in Xamarin Forums. Users complain about getting errors I can hardly reproduce. There's no way to test this while debugging.

HockeyApp gives me this error when they switch x times back and forth between the pages and then click on a button (and only a button), not a dropdown or other input fields. They render properly and I'm using the last version of Xamarin Forms.
Right now I'm only using Forms for Android, so I can only test this on Android.

<br /> Xamarin caused by: android.runtime.JavaProxyThrowable: System.ObjectDisposedException: Cannot access a disposed object.<br /> Object name: 'Xamarin.Forms.Platform.Android.Platform+DefaultRenderer'.<br /> Java.Interop.JniPeerMembers.AssertSelf(IJavaPeerable self)<bd30a18775d94dc8b6263aecd1ca9077>:0<br /> Java.Interop.JniPeerMembers.JniInstanceMethods.InvokeVirtualVoidMethod(string encodedMember, IJavaPeerable self, JniArgumentValue* parameters)<bd30a18775d94dc8b6263aecd1ca9077>:0<br /> Android.Views.View.SetBackgroundColor(Color color)<9ab9faae1b4b4f0da28e7c4ac61e2c78>:0<br /> Xamarin.Forms.Platform.Android.VisualElementRenderer<TElement>.UpdateBackgroundColor()<8783e2b68568446a8522c36407e66253>:0<br /> Xamarin.Forms.Platform.Android.VisualElementRenderer<TElement>.OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)<8783e2b68568446a8522c36407e66253>:0<br /> <Module>.invoke_void_object_PropertyChangedEventArgs(object, PropertyChangedEventArgs)(wrapper delegate-invoke)<br /> Xamarin.Forms.BindableObject.OnPropertyChanged(string propertyName)<6e20d7af277949f4a7bb952d64b81cda>:0<br /> Xamarin.Forms.Element.OnPropertyChanged(string propertyName)<6e20d7af277949f4a7bb952d64b81cda>:0<br /> Xamarin.Forms.BindableObject.SetValueActual(BindableProperty property, BindableObject.BindablePropertyContext context, object value, bool currentlyApplying, BindableObject.SetValueFlags attributes, bool silent)<6e20d7af277949f4a7bb952d64b81cda>:0<br /> Xamarin.Forms.BindableObject.SetValueCore(BindableProperty property, object value, BindableObject.SetValueFlags attributes, BindableObject.SetValuePrivateFlags privateAttributes)<6e20d7af277949f4a7bb952d64b81cda>:0<br /> Xamarin.Forms.BindingExpression.ApplyCore(object sourceObject, BindableObject target, BindableProperty property, bool fromTarget)<6e20d7af277949f4a7bb952d64b81cda>:0<br /> Xamarin.Forms.BindingExpression.Apply(bool fromTarget)<6e20d7af277949f4a7bb952d64b81cda>:0<br /> Xamarin.Forms.BindingExpression.BindingExpressionPart.<PropertyChanged>b__47_0()<6e20d7af277949f4a7bb952d64b81cda>:0<br /> Java.Lang.Thread.RunnableImplementor.Run()<9ab9faae1b4b4f0da28e7c4ac61e2c78>:0<br /> Java.Lang.IRunnableInvoker.n_Run(IntPtr jnienv, IntPtr native__this)<9ab9faae1b4b4f0da28e7c4ac61e2c78>:0<br /> at (wrapper dynamic-method) System.Object:94a3beb6-4f7c-4b9d-958e-0e8b8d73194b (intptr,intptr)<br /> mono.java.lang.RunnableImplementor.n_run(Native Method)<br /> mono.java.lang.RunnableImplementor.run()RunnableImplementor.java:30<br /> android.os.Handler.handleCallback()Handler.java:751<br /> android.os.Handler.dispatchMessage()Handler.java:95<br /> android.os.Looper.loop()Looper.java:154<br /> android.app.ActivityThread.main()ActivityThread.java:6120<br /> java.lang.reflect.Method.invoke(Native Method)<br /> com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run()ZygoteInit.java:865<br /> com.android.internal.os.ZygoteInit.main()ZygoteInit.java:755<br />

Because of a memoryleak in Forms, I had to change it to images with FFImageLoading.
Unfortunately, I cannot post much code, but this is the grid row that keeps crashing:
<br /> <?xml version="1.0" encoding="utf-8" ?><br /> <Grid xmlns="n.com/schemas/2014/forms" xmlns:x="ft.com/winfx/2009/xaml" xmlns:forms="clr-namespace:FFImageLoading.Forms;assembly=FFImageLoading.Forms" xmlns:extensions="clr-***.Extensions;assembly=***" x:Class="***.Views.Editors.BooleanEditor" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Padding="5,0" x:Name="Grid" IsVisible="{Binding Visible}" HeightRequest="80"><br /> &lt;Grid.RowDefinitions><br /> <RowDefinition Height="80"/><br /> &lt;/Grid.RowDefinitions></p> <p>&lt;Grid.ColumnDefinitions><br /> <ColumnDefinition Width=".2*"/><br /> <ColumnDefinition Width="1*"/><br /> <ColumnDefinition Width="3*"/><br /> <ColumnDefinition Width="1*"/><br /> <ColumnDefinition Width="6*"/><br /> <ColumnDefinition Width=".5*"/><br /> <ColumnDefinition Width="1*"/><br /> <ColumnDefinition Width=".5*"/><br /> <ColumnDefinition Width="1*"/><br /> <ColumnDefinition Width=".5*"/><br /> &lt;/Grid.ColumnDefinitions></p> <p>&lt;Grid.Children><br /> <forms:CachedImage Grid.Row="0" Grid.Column="0" WidthRequest="24" HeightRequest="24" DownsampleHeight="24" DownsampleWidth="24" Source="{extensions:ImageResource ***.Images.info.png}" HorizontalOptions="Start" VerticalOptions="Center" IsVisible="{Binding HasMemo}" CacheType="All" Margin="15,0,0,0"><br /> &lt;forms:CachedImage.GestureRecognizers><br /> <TapGestureRecognizer Command="{Binding BindingContext.ItemHelpCommand, Source={x:Reference Grid}}"/><br /> &lt;/forms:CachedImage.GestureRecognizers><br /> </forms:CachedImage></p> <pre><code><ContentView Grid.RowSpan="1" Grid.Row="0" Grid.Column="2" VerticalOptions="FillAndExpand"> <StackLayout Spacing="0" VerticalOptions="End" Margin="0,0,0,25"> <StackLayout Spacing="0"> <Label HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" HorizontalTextAlignment="Start" VerticalTextAlignment="Center" Text="{Binding Name}" FontSize="14"/> </StackLayout> <Label IsVisible="{Binding Required, Converter={StaticResource InvertBoolean}}" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" HorizontalTextAlignment="Start" VerticalTextAlignment="End" Text="{extensions:Translate DynamicFormOptional}" FontSize="10"/> </StackLayout> </ContentView> <ContentView BackgroundColor="{Binding BgColor}" Grid.Row="0" Grid.Column="4" Margin="0,0,0,12"> <Grid> <Grid.RowDefinitions> <RowDefinition Height="20"/> <RowDefinition Height="*"/> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/> </Grid.ColumnDefinitions> <Grid.Children> <Label Grid.Row="0" Grid.Column="0" HorizontalOptions="Start" VerticalOptions="FillAndExpand" HorizontalTextAlignment="Start" VerticalTextAlignment="Center" Text="{Binding PreviousValue, Converter={StaticResource TextTranslation}}" IsVisible="{Binding BindingContext.ValueHasChanged, Source={x:Reference Grid}}" /> <Label Grid.Row="0" Grid.Column="0" HorizontalOptions="Start" VerticalOptions="FillAndExpand" HorizontalTextAlignment="Start" VerticalTextAlignment="Center" IsVisible="{Binding BindingContext.ValueHasChanged, Source={x:Reference Grid}, Converter={StaticResource InvertBoolean}}" /> <forms:CachedImage VerticalOptions="Center" Grid.Row="1" Grid.Column="0" DownsampleToViewSize="True" Source="{extensions:ImageResource ***.Images.buttonNoOff.png}" IsVisible="{Binding Value, Converter={StaticResource NullableBoolean}, ConverterParameter=True}" CacheType="All"> <forms:CachedImage.GestureRecognizers> <TapGestureRecognizer Command="{Binding BindingContext.BooleanNoCommand, Source={x:Reference Grid}}"/> </forms:CachedImage.GestureRecognizers> </forms:CachedImage> <forms:CachedImage VerticalOptions="Center" Grid.Row="1" Grid.Column="0" DownsampleToViewSize="True" Source="{extensions:ImageResource ***.Images.buttonNoOn.png}" IsVisible="{Binding Value, Converter={StaticResource InvertNullableBoolean}}" CacheType="All"> <forms:CachedImage.GestureRecognizers> <TapGestureRecognizer Command="{Binding BindingContext.BooleanNoCommand, Source={x:Reference Grid}}"/> </forms:CachedImage.GestureRecognizers> </forms:CachedImage> <forms:CachedImage VerticalOptions="Center" Grid.Row="1" Grid.Column="1" WidthRequest="147" HeightRequest="100" DownsampleHeight="40" DownsampleWidth="147" DownsampleToViewSize="False" Source="{extensions:ImageResource ***.Images.buttonYesOff.png}" IsVisible="{Binding Value, Converter={StaticResource InvertNullableBoolean}, ConverterParameter=True}" CacheType="All"> <forms:CachedImage.GestureRecognizers> <TapGestureRecognizer Command="{Binding BindingContext.BooleanYesCommand, Source={x:Reference Grid}}"/> </forms:CachedImage.GestureRecognizers> </forms:CachedImage> <forms:CachedImage VerticalOptions="Center" Grid.Row="1" Grid.Column="1" WidthRequest="147" HeightRequest="100" DownsampleHeight="40" DownsampleWidth="147" DownsampleToViewSize="False" Source="{extensions:ImageResource ***.Images.buttonYesOn.png}" IsVisible="{Binding Value, Converter={StaticResource NullableBoolean}}" CacheType="All"> <forms:CachedImage.GestureRecognizers> <TapGestureRecognizer Command="{Binding BindingContext.BooleanYesCommand, Source={x:Reference Grid}}"/> </forms:CachedImage.GestureRecognizers> </forms:CachedImage> </Grid.Children> </Grid> </ContentView> <forms:CachedImage Grid.RowSpan="2" Grid.Row="0" Grid.Column="6" WidthRequest="24" HeightRequest="24" DownsampleHeight="24" DownsampleWidth="24" DownsampleToViewSize="False" Source="{Binding HasIssue, Converter={StaticResource HasIssueBoolConverter}}" IsVisible="{Binding HasIssueColumn}" CacheType="All"> <forms:CachedImage.GestureRecognizers> <TapGestureRecognizer Command="{Binding BindingContext.HasIssueCommand, Source={x:Reference Grid}}"/> </forms:CachedImage.GestureRecognizers> </forms:CachedImage> <forms:CachedImage Grid.RowSpan="2" Grid.Row="0" Grid.Column="8" WidthRequest="24" HeightRequest="24" DownsampleHeight="24" DownsampleWidth="24" DownsampleToViewSize="False" Source="{Binding CameraIcon, Converter={StaticResource CameraIconConverter}}" IsVisible="{Binding PictureRequired}" CacheType="All"> <forms:CachedImage.GestureRecognizers> <TapGestureRecognizer Command="{Binding BindingContext.Photo, Source={x:Reference Grid}}"/> </forms:CachedImage.GestureRecognizers> </forms:CachedImage>

</Grid.Children>


<br /> public partial class BooleanEditor : Grid, IEditor<br /> {<br /> public BooleanEditor()<br /> {<br /> InitializeComponent();<br /> }</p> <pre><code> public EditorTypes EditorType => EditorTypes.Boolean; }

I have removed the
<br /> BackgroundColor="{Binding BgColor}"<br />
for testing, but that did not change anything.

Please please help me, I'm getting desperate.

Render layout asynchronously

$
0
0

Hello everybody!

My headline may sound much worse than it really is, but this is the first thing that came to mind =)
On my page is the View and ActivityIndicator.
First I load the data from the backend into my ViewModel.
Then I send the data to the View, and when it gets the data it starts to add the elements to its Grid (my own elments).
When it adds these elements, my ActivityIndiacator freezes.

Below is my code for adding items:

public static readonly BindableProperty WeeksProperty = BindableProperty.Create(
            "Weeks",
            typeof(List<WeekInfo>),
            typeof(ScheduleMonthView),
            propertyChanged: (bindable, value, newValue) =>
            {
                var days = (List<WeekInfo>)newValue;
                ((ScheduleMonthView)bindable).FillGrid(days);
            });
//...
private void FillGrid(List<WeekInfo> weeks)
        {
            if (ReferenceEquals(weeks, null))
                throw new NullReferenceException();

            if (weeks.Count != 6)
                throw new NullReferenceException();

            for (int row = 1; row < 7; row++)
            {
                FillRow(row, weeks[row - 1]);
            }

            MonthInfo.IsBusy = false;
        }

        private void FillRow(int row, WeekInfo weekInfo)
        {
            for (int i = 0; i < 7; i++)
            {
                var cell = CreateCellView(weekInfo.Days[i]);
                PasteItem(cell, i, row);
            }
        }

        private MonthCellTemplate CreateCellView(DayInfo day)
        {
            var template = new MonthCellTemplate
            {
                BindingContext = day,
                IsNoActiveMonth = Weeks[2].DateOfFirstDayOfWeek.Month != day.DayOfMonth.Month,
            };          

            Binding itemTappedCommandBinding =
                new Binding("ItemTappedCommand", source: this);

            template.SetBinding(MonthCellTemplate.ItemTappedCommandProperty,
                itemTappedCommandBinding);

            return template;
        }

        private void PasteItem(View view, int column, int row)
        {
            MonthGrid.Children.Add(view, column, row);
        }

How can I place a NavigationPage within Placeholder.Content?

$
0
0

I currently have a nav bar that populates PlaceHolder.Content with a new class.

void Departments(object sender, System.EventArgs e)
{
var page = new Departments();
PlaceHolder.Content = page.Content;

}

My issue is that the new page that is being shown doesn't allow me to navigate through without a NavigationPage root.
is there a way that I can make..

PlaceHolder.Content = NavigationPage(Page.Content)?

I understand that they are not of the same type. But what can i do to make this work? thanks all.

Youtube API projet no compiler

$
0
0

hello i'm debutant with xamarin form and i'm doing a demo app for testing youtube services (recovering videos from a playlist) worry i've got the following i have this error CS0656 C # Member required by the compiler 'Microsoft.CSharp.RuntimeBinder .Binder.Convert 'missing which does not impede compiled the project and I checked the dependencies are well installed ... I followed this Tuto for realized
https://channel9.msdn.com/Blogs/MVP-Windows-Dev/Using-Youtube-API-with-Xamarin-Forms
Thank you

How to scrolling the Webview

$
0
0

Hi all,

We have an image gallery kind of view which shows only a single image or PDF file per a given time (fitted to screen).
User can navigate back and forward to see other images/PDFs with horizontal panguesture.
XAML is like below.


We have a custom content view which will represent an image(to show image) or a WebView(to show PDF) based on the file type to be displayed.
MainContainer is populated with above custom content views based on data source attached with the Gallery.
TouchContainer which in on top of MainContainer will handle all Pan, Pinch and Tap gestures for the Gallery.
Based on current gesture on TouchContainer behaviors of active custom content view (image or PDF) will be decided.

Issue comes with multiple page PDFs. They can be scrolled properly when loaded separately with custom WebView. But scrolling not functions in the Gallery as TouchContainer is on top of the WebView.

How to resolve this? How can I pass scrolling behavior to the PDF WebView as done with other gestures?

Thanks
Kaushalya

Prism: Back button on Android closes app when popup is open

$
0
0

Hello everyone,

I was working with popups in Prism. With the following code:

_navigationService.NavigateAsync(nameof(TestPopup));

The popup is added to the navigation stack. Therefore, I expect it go to the previous page when pressing the Android hardware back button. Too bad, it doesn't, it just closes the app (because there is nothing more in the navigation stack?)

Here is a test project where I reproduced it in:
https://github.com/GyllionElderen/PrismPopupTest

Does anyone know what to do to make the app go back to the root page instead of closing the app?

UWP - error APPX1101: Payload contains two or more files

$
0
0

I've been banging my head against the wall on this one - it happens on a freshly cloned repo

Its a Forms PCL project with UWP. I am using a ACR.Settings which requires me to install the nuget on the UWP project and the Forms project. I have no idea the cause. Here is the full error, an ideas?

E:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Microsoft\VisualStudio\v15.0\AppxPackage\Microsoft.AppXPackage.Targets(1748,5): error APPX1101: Payload contains two or more files with the same destination path 'Acr.Settings.pdb'. Source files: [E:\wp\SmartFill\SMC-1-setup-uwp-jenkins-build\SmartCart.UWP\SmartCart.UWP.csproj] E:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Microsoft\VisualStudio\v15.0\AppxPackage\Microsoft.AppXPackage.Targets(1748,5): error APPX1101: C:\Users\jenkins\.nuget\packages\acr.settings\7.0.2\lib\uap10.0\Acr.Settings.pdb [E:\wp\SmartFill\SMC-1-setup-uwp-jenkins-build\SmartCart.UWP\SmartCart.UWP.csproj] E:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Microsoft\VisualStudio\v15.0\AppxPackage\Microsoft.AppXPackage.Targets(1748,5): error APPX1101: E:\wp\SmartFill\SMC-1-setup-uwp-jenkins-build\SmartCart.Forms\bin\Debug\Acr.Settings.pdb [E:\wp\SmartFill\SMC-1-setup-uwp-jenkins-build\SmartCart.UWP\SmartCart.UWP.csproj]


Activate Tab using Prism

$
0
0

I am using Prism with my Xamarin Forms application. I have a home page with two tabs- A and B. Tab A has a button which when pressed should activate Tab B. How can I do that with Prism? Both the tabs have separate view models and each view model implements IActiveAware. I am currently using Event Aggregator but that seems really unnecessary to me for just activate tab?

Thanks

Apurva

Xamarin Media Plugin doesn't works on Android

$
0
0

Hi,
I've installed the plugin "Xam.Plugin.Media".
The plugin works fine on IOS but on Andorid the app crash as soon it starts.

I have followed the readme.txt that come after the installation of the plugin, so my files are:

MainActivity.cs:

using System;

using Android.App;
using Android.Content.PM;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
using Plugin.Permissions;
using Plugin.Permissions.Abstractions;
using FFImageLoading.Forms.Droid;

namespace SgatMobileV2.Droid {
    [Activity(Label = "SgatMobileV2", Icon = "@drawable/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
    public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity {
        protected override void OnCreate(Bundle bundle) {
            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource = Resource.Layout.Toolbar;

            base.OnCreate(bundle);

            global::Xamarin.Forms.Forms.Init(this, bundle);

            CachedImageRenderer.Init(enableFastRenderer: true); // Inizializza il plugin FFImageLoading

            LoadApplication(new App());
        }

        public override void OnRequestPermissionsResult(int requestCode, string[] permissions, global::Android.Content.PM.Permission[] grantResults) {
            PermissionsImplementation.Current.OnRequestPermissionsResult(requestCode, permissions, grantResults);
        }
    }
}

Resources/xml/file_paths.xml:

<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
  <external-files-path name="my_images" path="Pictures" />
  <external-files-path name="my_movies" path="Movies" />
</paths>

AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="it.volos.SgatMobile" android:installLocation="auto">
  <uses-sdk android:minSdkVersion="23" android:targetSdkVersion="26" />
  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
  <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
  <uses-permission android:name="android.permission.CAMERA" />
  <application android:label="SgatMobileV2.Android" android:icon="@drawable/icon">
    <provider android:name="android.support.v4.content.FileProvider" android:authorities="it.volos.SgatMobile.fileprovider" android:exported="false" android:grantUriPermissions="true">
      <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths"></meta-data>
    </provider>
  </application>
</manifest>

But after the app starts, this error is triggered:

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

Can anyone help me please?

Thank you!

How to serialize an Image object?

$
0
0

Is this even possible? If it is not possible, is there a way to convert Image object to Byte array?

Preserving layout...Is there a means in Xamarin Forms to force the preservation of the layout?

$
0
0

I have a label that shows a title above an entry box, the request is to have the label appear only when the entry box contains data. When the entry box does not contain data, show the placeholder text and hide the label. That was the easy part, the difficult part is preventing the page layout from changing when the label is hidden or the text property is set to an empty string. So essentially what I am being asked to do is to preserve the layout regardless of the content of the label or the visibility of the label...Is there a means in Xamarin Forms to force the preservation of the layout? What it is currently happening; when the entry is blanked out the label appears (the page/controls shift down to allow the label to appear), when text is entered into the entry control the label blanks out and the page/controls shift up)...the shifting is the problem. Please see the code snippet below:

                <StackLayout 
                    x:Name="stkAccountID"
                    Grid.Row="0"
                    VerticalOptions="Start">
                    <Label Text="" Style="{StaticResource BaseSmallLabelSyle}" IsVisible="True">
                        <Label.Triggers>
                            <DataTrigger TargetType="Label" Binding="{Binding Source={x:Reference entAccountID}, Path=Text.Length}" Value="0">
                                <!--<Setter Property="IsVisible" Value="false" />-->
                                <Setter Property="Text" Value="{ artina:Translate LabelAccountID }" />
                            </DataTrigger>
                        </Label.Triggers>
                    </Label>
                    <Entry x:Name="entAccountID" Placeholder="{ artina:Translate LabelAccountID }" Style="{StaticResource ArtinaLoginEntryStyle}" 
                           Text="{Binding AccountID}" Keyboard="Numeric">
                        <Entry.Behaviors>
                            <local:AccountIDValidationBehavior x:Name="entAccountIDValidator" MaxLength="5" />
                        </Entry.Behaviors>
                    </Entry>
                    <Label
                        Text="{ artina:Translate ErrorPleaseEnterValidAccountID }"
                        IsVisible="false"
                        Style="{StaticResource ValidationEntryErrorStyle}">

                        <Label.Triggers>
                            <DataTrigger TargetType="Label" Binding="{Binding Source={x:Reference entAccountIDValidator}, Path=IsValid}" Value="false">
                                <Setter Property="IsVisible" Value="true" />
                            </DataTrigger>
                        </Label.Triggers>
                    </Label>
                </StackLayout>

How to get entries ID?

$
0
0

Hi I have some entries and for each entry I have to set a min and max value, and I intend to use a switch case in the unfocused event but I don't know how to get entries IDs. Here is my code

       private void FocusChange(object sender, FocusEventArgs e)
        {
            ExtendedEntry entry = (ExtendedEntry)sender;
            if (entry.IsFocused)
            {
                entry.BackgroundColor = Color.Yellow;
                entry.Tag = entry.Text;
            }
            else
            {
                if (entry.Text.Trim().Length == 0)
                {
                    entry.Text = entry.Tag;                    
                }
                entry.BackgroundColor = Color.FromHex("#eee");               
                switch(entry.Id)
                {

                }
}

My goal is that when user enters a number that is out of range, i.e larger than the max value, and then clicks Done button, the entry value will be set back to the oldValue

Viewing all 58056 articles
Browse latest View live


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