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

Shell: Register routes when app starts (before you start AppShell

$
0
0

Hi there
in my main AppShell I register routes like this
[code]
public partial class MainPage : Xamarin.Forms.Shell
{
public MainPage()
{
InitializeComponent();
RegisterRoutes(); //Register page route so we can navigate to the page
}

    //Register page route so we can navigate to the page
    public void RegisterRoutes()
    {
        Routing.RegisterRoute("showImage", typeof(ShowImagePage));
    }
}

[/code]
if I first start the app so it goes to a home page I can navigate to here fine
my App.xaml.cs looks like this
[code]
public partial class App : Application
{
public App()
{
InitializeComponent();

        MainPage = new MainPage();
    }

    protected override void OnStart()
    {
        // Handle when your app starts
    }

    protected override void OnSleep()
    {
        // Handle when your app sleeps
    }

    protected override void OnResume()
    {
        // Handle when your app resumes
    }

    //Show image that user wants to share with our app
    public void ShowImage() //this method couses problems if I call this method direcly from native part b4 my app shows home page my app will crash
    {
        Task.Run(async () => await Shell.Current.GoToAsync("showImage")); //Go to the route we registered
    }

[/code]

but in my Native part I hook insto share dialog and want to show this showImage page when user shares a file
[code]
[Activity(Label = "clip2url", Icon = "@drawable/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
[IntentFilter(new[] { Intent.ActionSend }, Categories = new[] { Intent.CategoryDefault }, DataMimeType = @image/jpeg)] //Declaration to handle incoming files via share dialog
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
protected override void OnCreate(Bundle savedInstanceState)
{
TabLayoutResource = Resource.Layout.Tabbar;
ToolbarResource = Resource.Layout.Toolbar;

        base.OnCreate(savedInstanceState);

        global::Xamarin.Forms.Forms.SetFlags("Shell_Experimental", "Visual_Experimental", "CollectionView_Experimental", "FastRenderers_Experimental");
        Xamarin.Essentials.Platform.Init(this, savedInstanceState);
        global::Xamarin.Forms.Forms.Init(this, savedInstanceState);

        //Init Xmarin Plugins
        ImageCircle.Forms.Plugin.Droid.ImageCircleRenderer.Init(); //Init native Image library

        //To get acsess to Xamarin Forms part
        var mainForms = new App();
        LoadApplication(mainForms);

        //Here we tell out app what do we want to do with this share dialog data
        if (Intent.Action == Intent.ActionSend)
        {
            mainForms.ShowImage(); //here I call my ShowImage method and I want the page to be displayed but now my home page a seperate page and I want to then navigate back to home page
        }
    }
    public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Android.Content.PM.Permission[] grantResults)
    {
        Xamarin.Essentials.Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults);

        base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
    }
}

[/code]

now if I start the app from home screen then try to share file it works fine, but if I start my app from share dialog, then my app crashes as routes for some reason don't get registered and I cannot navigate to my ShowImage page if I didn't first open my MainPage

Hope someone can shed some light to this and help me figure out whats is wrong :smile:

Thanks


How to add space between bullet and List item in a HTML text in Xamarin forms

$
0
0

Hi,

I am trying to load HTML content in a Label, for that i am getting data from web service as

Things to do with this announcement:

  • Identify items you stock that are impacted
  • Review your sales and stop reordering poor sellers to help sell down restricted product
  • Assign a captain to ensure all restricted product is removed July 1, 2020

Please reach out with any questions or concerns:

I need space between bullet point and List item(

items)

Can anyone tell me how to do this in xamarin forms.

Thanks

CollectionView bug

$
0
0

Hi guys! Im using Xamarin.Forms 4.7 in my project and have issue with CollectionView.
This bug appears only on iOS and is displayed in approximately one build out of 10. I guess that bottom tabbed page causes this issue. Is there any ways to fix this?

How to convert a picture path to mediafile?

$
0
0

I have a picture file path and I am trying to upload this picture to server. When I upload this picture to server I need it's GetStream() value. I will show a sample code, that I have used in another place:

var content = new MultipartFormDataContent();
content.Add(new StreamContent(_mediaFile.GetStream()), "\"file\"", $"\"{_mediaFile.Path}\"");
var response = await httpClient.PostAsync(new Uri("My REST API"), content);

if (response.IsSuccessStatusCode)
{
   //Success
}

Where _mediaFile is a MediaFile

private MediaFile _mediaFile;

But currently, I have only the picture path. So is there any way to convert the picture path to MediaFile or anyway way to get the GetStream() value of the picture path?

Pagination in Listview

$
0
0

Hi all, I have nearly 1000 records in my ListView I need to show 100 records in each page. Can any one please help me on how to add Pagination in ListView. Any sample code or proper link on how to implemented will be very helpful!!

Thank you.

Move in image only possible in two directions

$
0
0

Hi All,

I have a code where I have an image which the user can zoom and move the image when zoomed. I face two difficulties here and I hope someone can help:

  • I can move the image in only two directions: left and up. It seems to be fixed to the right and downward somehow.
  • I want that the user can only move the image left, right, up and down when zoomed. Moving the image can now already be done without any zooming, which looks a bit strange.

I have a small demo in the attachment (tested on Android).

Hope someone can help!

Regards, Ganesh

Is it correct to use Xamarin.Forms namespace in a ViewModel

$
0
0

I am a newbie in Xamarin.Forms and the architect in our team mentioned, if we wanted a clean architecture, we must avoid using Xamarin.Forms in ViewModel as it references Views directly so it actually doesn't decouple.

But in the most of the tutorials, guides I don't see this being followed.

Can anyone suggest what's the correct guideline, and how does it really support this decoupling? Does everyone follow the same?
Also, when I try to use buttonclick event via a Command class in the ViewModel, I can't use it without using Xamarin.Forms namespace.

How can I achieve pure decoupling without using the Command class?

My Button Command not working using FreshMVVM

$
0
0
Hello Devs! I was using FreshMVVM in my Xamarin Forms Project, I implement Button Command in my LoginPage but it seems the Button doesn't have any connection with the LoginPageModel, I use XF Material Library and the Register button which I bound to is the Last Control in the Page (to ease Navigation).
Here is the LoginPage.Xaml:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage
xmlns:local="clr-namespace:buziTrade.Pages"
xmlns:xamanimation="clr-namespace:Xamanimation;assembly=Xamanimation"
xmlns:material="clr-namespace:XF.Material.Forms.UI;assembly=XF.Material"
xmlns:yummy="clr-namespace:Xamarin.Forms.PancakeView;assembly=Xamarin.Forms.PancakeView"
mc:Ignorable="d"
x:Class="buziTrade.Pages.LoginPage"
NavigationPage.HasNavigationBar="False">
<ContentPage.Resources>
<ResourceDictionary>

<local:MultiTriggerConverter x:Key="dataHasBeenEntered" />

<!--<xamanimation:StoryBoard
x:Key="InfoPanelAnimation"
Target="{x:Reference InfoPanel}">
<xamanimation:FadeToAnimation
Duration="50"
Opacity="1" />
<xamanimation:TranslateToAnimation
TranslateY="0"
Easing="CubicIn"
Duration="100" />
</xamanimation:StoryBoard>-->

<xamanimation:FadeInAnimation
x:Key="FlexLayoutAnimation"
Target="{x:Reference MainPanel}"
Duration="300"/>

</ResourceDictionary>
</ContentPage.Resources>
<ContentPage.Content>
<Grid x:Name="MainPanel">
<Grid VerticalOptions="Start">

<!--<yummy:PancakeView BackgroundColor="#275685" VerticalOptions="Start"
Padding="10">
<Label Text="Login Form" FontSize="14" TextColor="#FFFFFF"
FontAttributes="Bold"/>
</yummy:PancakeView>-->

<Frame BackgroundColor="#275685"
HorizontalOptions="Center" WidthRequest="30"
HeightRequest="30" CornerRadius="5"
Margin="0, 40, 0, 0">
<Label Text="bt" TextColor="White" HorizontalOptions="Center"
VerticalOptions="Center" FontSize="Large"
FontAttributes="Bold"/>
</Frame>
<Label Text="buziTrade"
TextColor="#275685" VerticalOptions="EndAndExpand"
HorizontalOptions="CenterAndExpand" Margin="0,0,0,-30"/>
</Grid>

<Grid VerticalOptions="CenterAndExpand" Margin="20,60,20,0">
<StackLayout>

<material:MaterialTextField Margin="0,0,0,30"
Placeholder="Username" x:Name="UserName"
InputType="Text" MaxLength="10" TintColor="#EC8D34"
FloatingPlaceholderFontSize="10" ShouldAnimateUnderline="True"
AlwaysShowUnderline="True"/>

<material:MaterialTextField
Placeholder="Password" x:Name="Password"
InputType="Password" MaxLength="8" TintColor="#EC8D34"
FloatingPlaceholderFontSize="10" ShouldAnimateUnderline="True"
AlwaysShowUnderline="True"/>

<StackLayout Orientation="Horizontal" VerticalOptions="End"
FlowDirection="RightToLeft" Margin="0,30,0,0">
<material:MaterialButton BackgroundColor="#275685"
CornerRadius="5" Margin="15, 10, 0, 0" Text="Login"
TextColor="#FFFFFF" ButtonType="Elevated"
x:Name="BtnLog2" IsEnabled="False">
<Button.Triggers>
<MultiTrigger TargetType="Button">
<MultiTrigger.Conditions>
<BindingCondition Binding="{Binding Source={x:Reference UserName},
Path=Text.Length,
Converter={StaticResource dataHasBeenEntered}}"
Value="True"/>
<BindingCondition Binding="{Binding Source={x:Reference Password},
Path=Text.Length,
Converter={StaticResource dataHasBeenEntered}}"
Value="True"/>
</MultiTrigger.Conditions>
<Setter Property="IsEnabled" Value="True" />
</MultiTrigger>
</Button.Triggers>
</material:MaterialButton>

<material:MaterialButton
TextColor="Red" FontSize="13"
ButtonType="Flat"
BackgroundColor="Transparent"
PressedBackgroundColor="Transparent"
CornerRadius="5" Margin="0,10,0,0"
Text="Forgot Password!"
HorizontalOptions="EndAndExpand" />

<!--<material:MaterialButton
CornerRadius="5" Margin="0, 10, 0, 0"
Text="Forgot Password!" BackgroundColor="#FFFFFF"
TextColor="#FFFFFF" ButtonType="Text"
PressedBackgroundColor="Transparent"
x:Name="Btnforgot" HorizontalOptions="EndAndExpand"/>-->
</StackLayout>
</StackLayout>
</Grid>
<StackLayout Orientation="Horizontal" VerticalOptions="End" Margin="0, 0, 0, 90">
<BoxView HorizontalOptions="StartAndExpand" VerticalOptions="Center" BackgroundColor="#275685" HeightRequest="2"
WidthRequest="150"/>
<Label Text="OR" HorizontalOptions="Center" VerticalOptions="Center" TextColor="#275685"/>
<BoxView HorizontalOptions="EndAndExpand" VerticalOptions="Center" BackgroundColor="#275685" HeightRequest="2"
WidthRequest="150"/>
</StackLayout>

<material:MaterialButton
CornerRadius="5" Margin="0, 0, 0, 30"
Text="Register Here" BackgroundColor="#FFFFFF"
TextColor="#275685" ButtonType="Text"
PressedBackgroundColor="Transparent"
x:Name="BtnRegister" VerticalOptions="End"
Command="{Binding RegisterCommand}" />

</Grid>
</ContentPage.Content>
</ContentPage>

and this is the LoginPageModel:

using FreshMvvm;
using PropertyChanged;
using System.Threading.Tasks;
using System.Windows.Input;
using Xamarin.Forms;

namespace buziTrade.PageModels
{
[AddINotifyPropertyChangedInterface]
public class LoginPageModel : FreshBasePageModel
{
public ICommand RegisterCommand => new Command(async () => await RegisterPage());


public LoginPageModel()
{

}

public override void Init(object initData)
{
base.Init(initData);
}

private async Task RegisterPage()
{
await CoreMethods.PushPageModel<RegisterPageModel>();
}

}
}

@MichaelRidland @Martijn00

How to Apply Style to particular Class name Div (HTML text) in Xamarin forms

$
0
0

Hi,

I am trying to load HTML content in a Label. I am getting Data like

April 1:

Due to revised NSPS emission limits for new room heaters, several wood stoves currently stocked in the RSCs will not be EPA compliant in 2020 and need to be sold or destroyed by May 15. AS OF MAY 15, YOU CANNOT SELL THESE UNITS TO CONSUMERS.

Vendors will not be taking back inventory of these units, so you are advised to sell through any stock on hand prior to the May 15, 2020 deadline. All impacted units on-hand as of May 15 are deemed unsellable and will need to be salvaged.

Please see the list of impacted SKUs and previous notices about this upcoming stop sale below for additional details.

 

Feb. 26, 2020:

We have added a $100 Instant Savings ONLINE to two U.S. Stove Wood Burning Stoves to help sell-through current inventory. These stoves are Ace Nos. 4639712 (54000 BTU 900 sq. ft. Wood Stove – 1269E) and 4639720 (94000 BTU 1600 sq. ft. Wood Stove – 2469E). We will honor the $100 for any stores who price matches the online price. Please contact the Ace Retailer Care Center to complete the instant savings reimbursement process.

 

Dec. 13, 2019:

In 2020, the NSPS emission limit for new room heaters will be lowered to 2.0 grams per hour if tested with crib wood*, or 2.5 grams per hour if tested with cord wood*.

All new wood heating appliances subject to the New Source Performance Standard for New Residential Wood Heaters under the Clean Air Act offered for sale in the United States are required to meet these emission limits.

As a result, several wood stoves currently stocked in the RSCs will not be EPA compliant in 2020 and need to be sold or destroyed by May 15. AS OF MAY 15, YOU CANNOT SELL THESE UNITS TO CONSUMERS. We are working with all vendors on transition plans for all existing stoves impacted by this regulation. We will continue to post subsequent communication in addition to specific action plans for all impacted stoves. We are closely monitoring inventory in the RSCs as well to ensure we're able to supply the demand this season, but not put anyone at risk of overstock in the Spring.

Attached is the list of the impacted Pellet and Wood Burning Stoves that will need to be sold before the May 15 deadline. Setup of replacement SKUs are in process and will be communicated once available on ACENET.

Submitted by: Daniel Kosinski – Merchandising

I have a div with class name "MobileBody". I want to apply style to it.
I tried the below one but it is working for only IOS, for Android All style tags are displaying ...
if (DeviceInfo.Platform.ToString() == "iOS")
{
ParagraphDesc = ".mobileBody{font-family:Roboto Slab; font-size:14px}" + responseData.BodyContent;
}

Can any one help on this

Pass List to another View and Display it

$
0
0

Hi. I'm trying to pass a List from one view to another, using the MVVM pattern. In my project, I want to store the questions from a List (questions) into another list (errores) and I want to display "errores" in another view. Basically, whenever the wrong True/False button is pressed, I want to store the question into "errores".

Here's what I've tried:

{
    private List<string> errores;

    public RESULTSPAGE2(List<string> errores)
    {
        InitializeComponent();

        MainListView.ItemsSource = errores;


    }


    }
}

//RESULTSPAGE2.xaml
<ContentPage.Content>
        <StackLayout>
            <ListView 
             x:Name="MainListView"   />
        </StackLayout>
    </ContentPage.Content>
</ContentPage>








class QuizPageModel : INotifyPropertyChanged
{
    public event PropertyChangedEventHandler PropertyChanged;

    void OnPropertyChanged([CallerMemberName] string name = "")
    {
        PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
    }

    public List<Question> questions;

    List<string> errores = new List<string>();



    private string _textopregunta;

    public string TextoPregunta
    {
        get
        {
            return _textopregunta;
        }

        set
        {
            _textopregunta = value;
            OnPropertyChanged();
        }
    }

    //Add Color
    /* private Color _BackgroundFalseButton;

     public Color BackgroundFalseButton
     {
         get
         {
             return _BackgroundFalseButton;
         }
         set
         {
             _BackgroundFalseButton = value; //You must implement INotifyChanged
             OnPropertyChanged(nameof(BackgroundFalseButton));
         }

     }*/



    private bool _wrongAnswer;
    public bool WrongAnswer
    {
        get
        {
            return _wrongAnswer;
        }

        set
        {
            _wrongAnswer = value;
            OnPropertyChanged();
        }
    }


    private bool _currentAnswerValue;
    public bool CurrentAnswerValue
    {
        get
        {
            return _currentAnswerValue;
        }

        set
        {
            _currentAnswerValue = value;
            OnPropertyChanged();
        }
    }

    private int _totalQuestions;
    public int TotalQuestions
    {
        get
        {
            return _totalQuestions;
        }

        set
        {
            _totalQuestions = value;
            OnPropertyChanged();
            OnPropertyChanged(nameof(TitleText));
        }
    }

    private int _currentQuestionNumber;
    public int CurrentQuestionNumber
    {
        get
        {
            return _currentQuestionNumber;
        }

        set
        {
            _currentQuestionNumber = value;
            OnPropertyChanged();
            OnPropertyChanged(nameof(TitleText));
        }
    }

    public string TitleText
    {
        get { return $"Question {_currentQuestionNumber} of {_totalQuestions}"; }
    }

    private int score;

    private Random random;

    public Command AnsweredTrue { get; }
    public Command AnsweredFalse { get; }
    public string QuestionText { get; }



    public QuizPageModel()
    {
        // initialise RNG
       random = new Random();

        // populate question list - replace with external data source in production
        questions = new List<Question>()
        {
            new Question() { QuestionText="1=2", Answer=false } ,
            new Question() { QuestionText="2+2=3", Answer=false },
            ..........
        };



            // initialise quiz values
            TotalQuestions = questions.Count;
        CurrentQuestionNumber = 1;
        score = 0;

        // load first question
        LoadQuestion();



        //True/False

        AnsweredTrue = new Command<Question>(async (question) =>
        {
            Debug.WriteLine("True button pressed");


            /* AnsweredTrue = new Command(async () =>
             {
             Debug.WriteLine("True button pressed");*/

            // check if answer is correct
            if (_currentAnswerValue == true)

                score++;



            else
            {

                errores.Add(QuestionText);


            }


        // load next question or results page
        if (CurrentQuestionNumber < TotalQuestions)
        {
            // increase question counter
            CurrentQuestionNumber++;
            LoadQuestion();
        }
        else
        {
            Debug.WriteLine("End of Quiz");
            await ShowResults().ConfigureAwait(false);
        }
    });



        AnsweredFalse = new Command(async () =>
        {
            Debug.WriteLine("False button pressed");



            // check if answer is correct
            if (_currentAnswerValue == false)
                score++;

            else
            {
                errores.Add(QuestionText);
                //_wrongAnswer = true;

            }


        /*    if (_wrongAnswer == true)
            {
                errores.Add(QuestionText);

            }

            */

        // load next question or results page
        if (CurrentQuestionNumber < TotalQuestions)
        {
            // increase question counter
            CurrentQuestionNumber++;
            LoadQuestion();
        }
        else
        {
            Debug.WriteLine("End of Quiz");
            await ShowResults().ConfigureAwait(false);
        }
    });
    }


    private void LoadQuestion()
    {
        var index = random.Next(questions.Count);
        TextoPregunta = questions[index].QuestionText;
        CurrentAnswerValue = questions[index].Answer;
        questions.RemoveAt(index);
    }

    // private async Task ShowResults() => await Application.Current.MainPage.Navigation.PushAsync(new LVTest(score, _totalQuestions, errores)).ConfigureAwait(false);
    private async Task ShowResults() => await Application.Current.MainPage.Navigation.PushAsync(new RESULTSPAGE2(errores));

}

}

TabbedPage event on tab click or refresh tab when same tab is clicked?

$
0
0

I'm using a TabbedPage with Xamarin.Forms, and when a user is already on Tab 2, and clicks on Tab 2, I'd either like that tab to reload, or i'd like to run my own custom code to refresh the page.

I have been trying to find any sort of event I could hook into, or a way to do this with custom renderers but have been unable to find anything. What's the simplest way to do this?

Thanks!

iOS App crashing when binding to Text & IsVisible

$
0
0

I'm having issues with binding in iOS. We have numerous forms in our app and they're broadly set out as per the example with an Entry and an associated label for validation feedback - we're using FluentValidation for this. The label is hidden unless there are errors to show, this is so they take up no space on the interace when not required.

<Entry x:Name="UsernameEntry" 
    Placeholder="{Binding UILabelLoginName}"
    IsTextPredictionEnabled="False"
    PlaceholderColor="#333333"
    TextColor="#000000" 
    ReturnType="Done"
        Text="{Binding LoginName.Value}"
        InputTransparent="False">
    <Entry.Behaviors>
        <behaviors:EventToCommandBehavior
            Command="{Binding ClearValidationCommand}"
            CommandParameter="LoginName"
            EventName="Focused" />
    </Entry.Behaviors>
</Entry>

<Label
    IsVisible="{Binding LoginName.IsValid, Converter={StaticResource InverseBoolean}}"
    Style="{StaticResource ErrorLabelStyle}"
        Text="{Binding LoginName.FirstError}" />

This works lovely in Android, in iOS though the binding to IsVisible crashes the app. If we set IsVisible to true as opposed to binding it and set a fixed HeightRequest then it works fine but I don't want empty labels taking up space within the forms.

Android - On Load

Android - On Error

iOS - On Load (IsVisible set to Binding)

iOS - On Error (IsVisible set to Binding)

  • Crash

iOS - On Load (IsVisible set to True)

iOS - On Error (IsVisible set to True)

The exception at the time of the crash is,

Object reference not set to an instance of an object

at Xamarin.Forms.Platform.iOS.VisualElementTracker.UpdateClip () [0x00072] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementTracker.cs:413
at Xamarin.Forms.Platform.iOS.VisualElementTracker.UpdateNativeControl () [0x0006c] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementTracker.cs:386
at Xamarin.Forms.Platform.iOS.VisualElementTracker.HandlePropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs e) [0x00064] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementTracker.cs:97
at (wrapper delegate-invoke) .invoke_void_object_PropertyChangedEventArgs(object,System.ComponentModel.PropertyChangedEventArgs)
at Xamarin.Forms.BindableObject.OnPropertyChanged (System.String propertyName) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:229
at Xamarin.Forms.Element.OnPropertyChanged (System.String propertyName) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Element.cs:353
at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.Internals.SetValueFlags attributes, System.Boolean silent) [0x00114] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:461
at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x00173] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:397
at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value, System.Boolean fromStyle, System.Boolean checkAccess) [0x00042] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:334
at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindablePropertyKey propertyKey, System.Object value) [0x0000e] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:318
at Xamarin.Forms.VisualElement.set_Height (System.Double value) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:324
at Xamarin.Forms.VisualElement.SetSize (System.Double width, System.Double height) [0x0001a] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:1081
at Xamarin.Forms.VisualElement.set_Bounds (Xamarin.Forms.Rectangle value) [0x0005d] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:316
at Xamarin.Forms.VisualElement.Layout (Xamarin.Forms.Rectangle bounds) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:708
at Xamarin.Forms.Layout.LayoutChildIntoBoundingRegion (Xamarin.Forms.VisualElement child, Xamarin.Forms.Rectangle region) [0x001da] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:178
at Xamarin.Forms.TemplatedView.LayoutChildren (System.Double x, System.Double y, System.Double width, System.Double height) [0x00019] in D:\a\1\s\Xamarin.Forms.Core\TemplatedView.cs:29
at Xamarin.Forms.Layout.UpdateChildrenLayout () [0x00158] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:266
at Xamarin.Forms.Layout.OnSizeAllocated (System.Double width, System.Double height) [0x0000f] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:224
at Xamarin.Forms.VisualElement.SizeAllocated (System.Double width, System.Double height) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:812
at Xamarin.Forms.VisualElement.SetSize (System.Double width, System.Double height) [0x00021] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:1083
at Xamarin.Forms.VisualElement.set_Bounds (Xamarin.Forms.Rectangle value) [0x0005d] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:316
at Xamarin.Forms.VisualElement.Layout (Xamarin.Forms.Rectangle bounds) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:708
at Xamarin.Forms.Layout.LayoutChildIntoBoundingRegion (Xamarin.Forms.View child, Xamarin.Forms.Rectangle region, Xamarin.Forms.SizeRequest childSizeRequest) [0x00225] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:319
at Xamarin.Forms.StackLayout.LayoutChildren (System.Double x, System.Double y, System.Double width, System.Double height) [0x00081] in D:\a\1\s\Xamarin.Forms.Core\StackLayout.cs:65
at Xamarin.Forms.Layout.UpdateChildrenLayout () [0x00158] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:266
at Xamarin.Forms.Layout.OnSizeAllocated (System.Double width, System.Double height) [0x0000f] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:224
at Xamarin.Forms.VisualElement.SizeAllocated (System.Double width, System.Double height) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:812
at Xamarin.Forms.Layout.ResolveLayoutChanges () [0x0005c] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:392
at Foundation.NSAsyncActionDispatcher.Apply () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.18.2.1/src/Xamarin.iOS/Foundation/NSAction.cs:152
--- End of stack trace from previous location where exception was thrown ---

at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.18.2.1/src/Xamarin.iOS/UIKit/UIApplication.cs:86
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0000e] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.18.2.1/src/Xamarin.iOS/UIKit/UIApplication.cs:65
at xxxx.iOS.Application.Main (System.String[] args) [0x00002] in C:\xxxx\xxxx.iOS\Main.cs:19

Any guidance would be very much appreciated!

Thanks

It's possible to add Tap gesture to the Entry?

$
0
0

Hi All,
As I wrote in the title, it's possible to add Tap gesture to the Entry?
This code works for Label but doesn't work for Entry:

var tapEntryRecognizer = new TapGestureRecognizer(); tapFocusEntryRecognizer.Tapped += async (s, e) => { Console.WriteLine("tapped"); }; tapEntry.GestureRecognizers.Add(tapFocusEntryRecognizer);

Works fine on emulator, but cause deployment error on real device

$
0
0

I worked with VS 2017 until recently, and changed to VS 2019.
I also updated Xamarin.Forms

I try a simple app with a service, which works fine on the emulator.
When I try to run it on a real device, I get the next deployment error:

ADB0010: Deployment failedMono.AndroidTools.InstallFailedException: Unexpected install output: pkg: /data/local/tmp/com.companyname.tryservice_proj-Signed.apkFailure [INSTALL_PARSE_FAILED_MANIFEST_MALFORMED] at Mono.AndroidTools.Internal.AdbOutputParsing.CheckInstallSuccess(String output, String packageName) in E:\A_work\963\s\External\androidtools\Mono.AndroidTools\Internal\AdbOutputParsing.cs:line 348

In my searching I've seen that possible reason can be that the name of the package begins with a Capital letter.
I've checked in AndroidManifest.xml and it begin with a small letter as it should

Any suggestion will be appreciated.

Polygon binding listview problem render

$
0
0

Good evening, I'm trying to create a listview with mvvm model with inside it a "Polygon" element in the item-template.
I have a button inside that allows you to hide / show elements and the RefreshListViewItem method is called from code at the click of the button .
On refreshing it would appear that the "Polygon" loses the data binding of the model.
Is anyone else having this problem?
Thank you!


GridItemsLayout in CollectionView to be flexible and Frame or border around collectionview item

$
0
0

Question 1. - Is there a way to get the Frames to be flexible ? I mean to get the frames in the bottom line to be closer to the upper line to close the gap.

Question 2. - Is there a way to get the collectionview items to separate frames or to get them a border like the frames has ?

<CollectionView IsGrouped="True" ItemsSource="{Binding DLHY_VYPIS}">
            <CollectionView.ItemsLayout>
                <GridItemsLayout Orientation="Vertical" Span="4" />
            </CollectionView.ItemsLayout>
            <CollectionView.GroupHeaderTemplate>
                <DataTemplate>
                    <Label x:Name="vyslednasuma" FontAttributes="Bold" Text="{Binding VyslednaSuma}" TextColor="{DynamicResource PrimaryTextColor}">
                        <Label.Triggers>
                            <DataTrigger TargetType="Label" Binding="{Binding Bool_farba_textu}" Value="True">
                                <Setter Property="TextColor" Value="{DynamicResource RedText}"/>
                            </DataTrigger>
                        </Label.Triggers>
                    </Label>
                </DataTemplate>
            </CollectionView.GroupHeaderTemplate>
            <CollectionView.ItemTemplate>
                <DataTemplate>
                    <StackLayout VerticalOptions="FillAndExpand">
                    <Frame CornerRadius="10" OutlineColor="{DynamicResource PrimaryTextColor}" Padding="5" Margin="5">
                        <StackLayout BackgroundColor="{DynamicResource PageBackgroundColor}" Padding="5">
                            <Label Text="{Binding Popis}" Margin="0" TextColor="{DynamicResource PrimaryTextColor}" BackgroundColor="{DynamicResource PageBackgroundColor}"/>
                            <Label Text="{Binding KEDY}" Margin="0" TextColor="{DynamicResource PrimaryTextColor}" BackgroundColor="{DynamicResource PageBackgroundColor}"/>
                            <Label Text="{Binding KOĽKO,StringFormat='{0:N}€'}" Margin="0" TextColor="{DynamicResource PrimaryTextColor}" BackgroundColor="{DynamicResource PageBackgroundColor}"/>
                            <!--<Button Text="DELETE" Command="{Binding Source={x:Reference DLHY_USER_}, Path=BindingContext.TEST}" CommandParameter="{Binding ID}"/>-->
                            <Image Source="delete_bin_icon" WidthRequest="15" HeightRequest="15" HorizontalOptions="End">
                                <Image.GestureRecognizers>
                                    <TapGestureRecognizer  Command="{Binding Source={x:Reference DLHY_USER_}, Path=BindingContext.TEST}" CommandParameter="{Binding ID}"/>
                                </Image.GestureRecognizers>
                            </Image>
                        </StackLayout>
                    </Frame>
                    </StackLayout>
                </DataTemplate>
            </CollectionView.ItemTemplate>
        </CollectionView>

Xamarin.Forms How to check if View that in Grid that in ScrollView is visible

$
0
0

I have the issue with Grid that is in ScrollView
Some View-s in Grid is out of screen, but when I try get IsVisible for each view inside of Grid it return true ...
But really this View is out of screen ... How to get from code that this View is not visible due to ScrollView ?

My Button Command Parameter not Working in FreshMVVM

$
0
0

Hello Devs! I was using FreshMVVM in my Xamarin Forms Project, I implemented Button Command Parameter in my LoginPage but it seems the Button doesn't have connect with the LoginPageModel, I use XF Material Library.

Here is the Register Button in LoginPage.Xaml:

<material:MaterialButton
 CornerRadius="5" Margin="0, 0, 0, 30"
Text="Register Here" BackgroundColor="#FFFFFF"
TextColor="#275685" ButtonType="Text"
PressedBackgroundColor="Transparent"
x:Name="BtnRegister" VerticalOptions="End"
Command="{Binding RegisterCommand}" />

and this is the LoginPageModel.cs:

using FreshMvvm;
using PropertyChanged;
using System.Threading.Tasks;
using System.Windows.Input;
using Xamarin.Forms;
namespace buziTrade.PageModels
{
[AddINotifyPropertyChangedInterface]
public class LoginPageModel : FreshBasePageModel
{
public ICommand RegisterCommand => new Command(async () => await RegisterPage());
public LoginPageModel()
{
}
public override void Init(object initData)
{
base.Init(initData);
}
private async Task RegisterPage()
{
await CoreMethods.PushPageModel<RegisterPageModel>();
}
}
}

@MichaelRidland @Martijn00

Crash: PdfSharp.Xamarin.Forms already initialized before

$
0
0

Hi all,

I use PDFSharp.Xamarin.Forms in my app (Android and iOS). I initiated the package in MainActiviy.cs:

This works in general, but sometimes I get a strange error which causes my app to crash:

System.InvalidOperationException: PdfSharp.Xamarin.Forms already initialized before

Where does this error come from and how to solve this?

AdMob update for Xamarin Forms

$
0
0

Does anyone know the most up-to-date way to use AdMob for android please? Since the breaking changes in version 17.0.0 of the SDK you can no longer use the same method James Montemagno uses, and his way is pretty much what is all over the internet.
By that I mean, he initialises ads using the app id in MainActivity.cs , now it is required to be in the AndroidManifest.xaml in a <metadata/> tag.

Also, if anyone knows how to make Native ads and consume them with forms I would love to have a resource or guide I can follow for this. Thanks in advance.

Viewing all 81910 articles
Browse latest View live


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