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

Unable to invoke Backdoor method

$
0
0

We are trying to invoke a backdoor method to bypass logging in as xamarin is unable to interact with the azure login page.

I have added the following to my MainActivity class

[Export("MyBackdoorMethod")]
public void MyBackdoorMethod()
{
System.Diagnostics.Debug.WriteLine("In through the backdoor - do some work");
}

I have also added this to my Test

    [Test]
    public void FirstLogin()
    {
        app.Screenshot("First screen.");
        app.Tap("Get Started");

        Thread.Sleep(TimeSpan.FromSeconds(10));

        app.Invoke("MyBackdoorMethod");

        app.Screenshot("Login Screen");
    }

But when executing the test I keep getting the following

System.Exception : Error while performing Invoke("MyBackdoorMethod", null)
----> System.Exception : Invoke for MyBackdoorMethod failed with outcome: ERROR
No such method found: MyBackdoorMethod()

How do I ensure the test is able to execute the method....??


Remove the background color of the Statusbar

$
0
0

need to remove the background color of the Statusbar( for android and ios platform), am using xamarin forms

After Adding Images in Resources Drawable Folder(PCL --> Android), I am getting these errors(142)

$
0
0


Including Image to the project leads to these errors. (lst1.png)

Any help?
Thanks in advance.

How do I display a list of data without using a list view and binding in xaml

$
0
0

I'm trying to display a list of objects that is contained in another list but the result is an exception, I want to do this


<ListView.ItemTemplate>






<ListView.ListTemplate>







</ListView.ListTemplate>





</ListView.ItemTemplate>

Parse iCal file in Xamarin PCL project?

$
0
0

As per the title, I'm trying to parse an iCal file in a Xamarin PCL project. There are various tools available, all with very poor documentation and support. I've used the DDay.iCal parser on a desktop application before, however this will not work on the PCL project. The DDay.iCal library is now obsolete and has been replaced by iCal.Net, which does seem to have a NuGet package designed for PCL projects, however always fails to install on my system. Plus, I've never been able to use iCal.Net due to lack of simple instructions, hence using DDay.iCal, it's simple and works.

I'm not exactly an expert on programming in general (still learning) and especially not Xamarin. I don't see why this is so difficult, all I want to do is read events from an iCal file, not create events, not create calendars, just read them. I have PCLStorage installed in my project and I'd get as basic as a stream reader and parse the thing myself if I could get it to work properly, but I can't find any help on doing that either.

Access C: drive from Xamarin Forms Application - UWP part

$
0
0

Hi,

am I right, that there is no way to access a folder that is located directly on the C drive?
This can only be done by using a picker and let the user open the folder?
Of course, after that I can store this path for further access. The reason why I'm asking is, that I want to "pool" some directorys for new files.
This files will be downloaded by using a Mobile Device Management tool.
And it wouldn't be userfriendly if they have to open the folder every time the app starts. Or at least, no one should be able to open any folders. Therefore a picker is not really an option.

Any idea how to handle that?

BR
flix101

Problems with complex view model binding and OnPropertyChanged call

$
0
0

Hello,
I'm trying to work with Xamarin Forms and XAML and I have a view which requires a relativly complex view model. The following example represents my current view model:

class MyContext : INotifyPropertyChanged {
    public BasicInfo Info { get; }
    public ObservableCollection<MyFirstListItem> firstListItems { get; }
    public ObservablleCollection <MySecondListItem> secondListItems { get; }

    public MyContext() {
        this.BasicInfo = new BasicInfo { Name = "The Machine!", Duration = 10 };
        this.firstListItems = new ObservableCollection<MyFirstListItem>(new[] {
            new MyFirstListItem { Part = 1, Topic = "Drinking" },
            new MyFirstListItem { Part = 2, Topic = "Waking Up" }
        });
        this.secondListItems = new ObservableCollection<MySecondListItem>(new[] {
            new MySecondListItem{ Title = "Some title", Duration: 120 },
            new MySecondListItem{ Title = "Some other title", Duration: 90 }
        });
    }

    public event PropertyChangedEventHandler PropertyChanged;
    public void OnPropertyChanged([CallerMemberName]string propertyName = "") => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}

The classes BasicInfo, MyFirstListItem and MySecondListItem are simple classes with getter/setter properties of primitive types.

In my page class I set the BindingContext to an instance of MyContext . And in the XAML part I can display all of the children without a problem. But when a child (e.g. the Title of one of the MySecondListItem instances) changes it is not changed in the GUI.
This resulted in several observations and questions:

  1. I'm pretty sure I need to call OnPropertyChanged whenever I change something. So it should be done in the setter methods. I got this from the Xamarin documentation. I've adapted the classes to call the OnPropertyChanged on the instance of the MyContext class. This didn't change anything. To make it clear: I called the OnPropertyChanged of the MyContext class in the setter of the Title property in the MySecondListItem class.
  2. What's the default way to bind complex classes? Is there a way to do mulitple bindings on the different elements of the GUI? Or is there only one BindingContext and I need to handle the OnPropertyChanged differently?

Any help on this would be greatly appreciated.

MediaManager Plugin and controlls

$
0
0

Hi,
I'm trying out the MediaManager plugin and get it to start with no problem with just this:

CrossMediaManager.Current.Play("https://archive.org/download/BigBuckBunny_328/BigBuckBunny_512kb.mp4", MediaFileType.Video);

My only problem is that I don't get any controlls, I just wan't to have the native ones but they don't show up. Do I have to call for them in some way?

Best regards
/magnus


[HttpClient.SendAsync] Works on emulator, not on phone (but used to)

$
0
0

Hello Guys!

Below follows my async call. It all used to work well but since my last compilation it does not work property on deployed phone (using archive - adhoc).

I'm feeling helpless since I have never been able to properly debug any Async method since the starting of this app's development in january this year.

I've tried to put the call under a try catch block and display de exception message on a display alert but had no success.

Can anyone give me directions on where to even start?

public class GymManager : BaseManager
{
public async Task<List> LoadGymsAsync(string GymName = "")
{
using (var httpClient = new HttpClient())
{
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", App.User.LastValidToken);

            var parameters = new List<KeyValuePair<string, string>>();

            parameters.Add(new KeyValuePair<string, string>("gymName", GymName));
            parameters.Add(new KeyValuePair<string, string>("dateAndTimeWanted", App.WorkoutInfo.From.ToString()));

            var url = CreateRequestURI("gym", null, parameters, RoutingOrQueryString.QueryString);

            using (var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, url))
            {
                // Sending Request
                using (var httpResponse = await httpClient.SendAsync(httpRequestMessage).ConfigureAwait(false))
                {
                    // Reading result
                    string readHttpResponse = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
                    // Deserializing json object and setting configure await as false to run code in background by running code in Task
                    var jsonObject = JsonConvert.DeserializeObject(readHttpResponse, typeof(List<GymDTO>), _settings);

                    return (List<GymDTO>)jsonObject;
                }
            }
        }
    }
}

Deploying to android emulator error:Could not load assembly 'System.Runtime.CompilerServices.Unsafe'

$
0
0

When trying to deploy Xamarin.Forms to android emulator the following message is displayed in VS2017 output window.

07-27 10:31:25.512 D/Mono ( 3680): Assembly Loader probing location: 'System.Runtime.CompilerServices.Unsafe'.
07-27 10:31:25.512 F/monodroid-assembly( 3680): Could not load assembly 'System.Runtime.CompilerServices.Unsafe' during startup registration.
07-27 10:31:25.512 F/monodroid-assembly( 3680): This might be due to an invalid debug installation.
07-27 10:31:25.512 F/monodroid-assembly( 3680): A common cause is to 'adb install' the app directly instead of doing from the IDE.

Initially the application could be deployed without any problems to the android emulator.
The last change that I did was adding a custom WebViewRender. Could the fail of the application deployment be related to that ?

Object reference not set to an instance of an object?

$
0
0

I have written a page in xaml. It runs smoothly without any problem on iOS but when it comes to android, An exception in thrown "Object reference not set to instance of an object " from
LoadApplication(new App());
of MainActivity.cs class.
Below is my XAML code:

<?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:local="clr-namespace:jldoubleu" x:Class="jldoubleu.jldoubleuPage">

    <AbsoluteLayout>

        <Image Source="logo.png" AbsoluteLayout.LayoutBounds="0.5,0,0.6,0.4" AbsoluteLayout.LayoutFlags="All"/>

 <Label HorizontalTextAlignment="Center" Text="Enrich My Group" FontSize="20" TextColor="Gray" AbsoluteLayout.LayoutBounds="0.53,0.25,0.5,0.05" AbsoluteLayout.LayoutFlags="All"/>

        <Entry Placeholder="Username or Email" PlaceholderColor="Gray" AbsoluteLayout.LayoutFlags="All" AbsoluteLayout.LayoutBounds= "0.5,0.32,0.7,0.08"/>
        <Entry Placeholder="Password" PlaceholderColor="Gray" AbsoluteLayout.LayoutFlags="All" AbsoluteLayout.LayoutBounds= "0.5,0.42,0.7,0.08"/>

        <Button AbsoluteLayout.LayoutBounds="0.5,0.52,100,40" AbsoluteLayout.LayoutFlags="PositionProportional" Text="Sign in" BackgroundColor= "#4db8ff" TextColor= "White" />

        <Button BackgroundColor="#00cc44" AbsoluteLayout.LayoutBounds="0.1,0.64,0.3,0.07" AbsoluteLayout.LayoutFlags="All" Text="Register"  TextColor= "White" />
        <Button BackgroundColor="#ff0066" AbsoluteLayout.LayoutBounds="0.8,0.64,0.5,0.07" AbsoluteLayout.LayoutFlags="All" Text="Password Reminder"  TextColor= "White" />


        <Button Image="fb.png" AbsoluteLayout.LayoutBounds="0.15,0.75,40,40" AbsoluteLayout.LayoutFlags="PositionProportional"  BackgroundColor="Transparent" />
        <Button  AbsoluteLayout.LayoutBounds="0.75,0.75,0.6,0.07" AbsoluteLayout.LayoutFlags="All" TextColor="White"  Text="Connect with Facebook" BackgroundColor="#0066cc"/>

        <Button Image="li.png" AbsoluteLayout.LayoutBounds="0.15,0.85,40,40" AbsoluteLayout.LayoutFlags="PositionProportional"  BackgroundColor="Transparent" />
        <Button  AbsoluteLayout.LayoutBounds="0.75,0.85,0.6,0.07" AbsoluteLayout.LayoutFlags="All" TextColor="White"   Text="Connect with Linked In" BackgroundColor="#004d99"  />

        <Button Image="g.png" AbsoluteLayout.LayoutBounds="0.15,0.95,40,40" AbsoluteLayout.LayoutFlags="PositionProportional"  BackgroundColor="Transparent" />
        <Button  AbsoluteLayout.LayoutBounds="0.75,0.95,0.6,0.07" AbsoluteLayout.LayoutFlags="All" TextColor="White"   Text="Connect with Google" BackgroundColor="#ff1a1a" />

    </AbsoluteLayout>
</ContentPage>

Forcefully deleted xamarin.form

$
0
0

After i Forcefully deleted xamarin.form nuget package,i can not see the package inside nuget list. now i need to install the xamarin.form package again.:(

PLz Plz help me....

ScrollToAsync not working on iOS page load

$
0
0

Hello all,
I'm currently having an issue with ScrollToAsync malfunctioning only on iOS. I have called ScrollToAsync with both overloads and everything has worked fine on Android but never seems to work on iOS. I have debugged the code and it is definitely getting called without exceptions.
If I call ScrollToAsync after the page load it works as intended.
Here is my code:

public class ConversationViewPage : MyStylePage
{
    Entry _messageEntry = null;
    Button _sendButton = null;
    StackLayout _messageLayout = null;
    ScrollView _messageScrollView = null;
    static Element _latestDetail = null;

    public ConversationViewPage(Conversation conversation)
    {
        _latestDetail = null;

        _messageEntry = new Entry
        {
            Placeholder = "Message...",
            VerticalOptions = LayoutOptions.End
        };
        _messageEntry.Focused += _messageEntry_Focused;

        _sendButton = new Button
        {
            Text = "Send",
            VerticalOptions = LayoutOptions.End
        };
        _sendButton.Clicked += _sendButton_Clicked;
        _messageEntry.Completed += _sendButton_Clicked;

        var stackLayout = new StackLayout
        {
            Padding = new Thickness(0, 20, 0, 0)
        };

        _messageLayout = new StackLayout
        {
            VerticalOptions = LayoutOptions.EndAndExpand
        };

        _messageScrollView = new ScrollView
        {
            VerticalOptions = LayoutOptions.EndAndExpand,
            Content = _messageLayout,
            Margin = new Thickness(5, 5)
        };
        _messageScrollView.SizeChanged += _messageScrollView_SizeChanged;

        stackLayout.Children.Add(_messageScrollView);
        stackLayout.Children.Add(_messageEntry);
        stackLayout.Children.Add(_sendButton);

        Content = stackLayout;
    }

    private async void _messageScrollView_SizeChanged(object sender, EventArgs e)
    {
        var stender = (ScrollView)sender;
        if (stender.ContentSize.Height > stender.Height && _latestDetail != null)
            await stender.ScrollToAsync(_latestDetail, ScrollToPosition.End, false); //Does not work on iOS. Does work on Android.
    }

    private async void _messageEntry_Focused(object sender, FocusEventArgs e)
    {
        await scrollToBottomOfMessages(); //This works perfectly
    }

    protected async override void OnAppearing()
    {
        base.OnAppearing();

        await populatePage();
    }

    private async Task populatePage()
    {
        var contents = GetAllMyData();

        _messageLayout.Children.Clear();

        foreach (var content in contents.OrderBy(x => x.TimeStamp))
        {
            var sender = this.Users.Single(u => u.Id == content.SenderId);
            var senderName = sender.FirstName + ' ' + sender.LastName;
            var detail = new ConversationDetail(content);
            _latestDetail = detail;

            _messageLayout.Children.Add(detail);
        }

        await scrollToBottomOfMessages(); //Does not work on iOS.
    }

    private async Task scrollToBottomOfMessages()
    {
        if (_latestDetail != null)
            await _messageScrollView.ScrollToAsync(_latestDetail, ScrollToPosition.End, false); //Does not work on page load in iOS
    }

    private async void _sendButton_Clicked(object s, EventArgs e)
    {
        var message = _messageEntry.Text.Trim();
        if (message.Length > 0)
        {
            _messageEntry.Text = string.Empty;

            var activityIndicator = new ActivityIndicator
            {
                IsRunning = true,
                IsEnabled = true
            };
            _messageLayout.Children.Add(activityIndicator);
            _latestDetail = activityIndicator;
            await scrollToBottomOfMessages(); //Works perfectly

            var sender = this.Users.Single(u => u.Id == addedMessage.SenderId);
            var senderName = sender.FirstName + ' ' + sender.LastName;

            var conversationDetail = new ConversationDetail(addedMessage);

            await AddNewMessageToDatabase(conversationDetail);

            _messageLayout.Children.Add(conversationDetail);
            _latestDetail = conversationDetail;
            _messageLayout.Children.Remove(activityIndicator);

            await scrollToBottomOfMessages(); //Works perfectly
        }
    }
}

Any ideas?

Visual Studio Erro

$
0
0

Severity Code Description Project File Line Suppression State
Warning IDE0006 Error encountered while loading the project. Some project features, such as full solution analysis for the failed project and projects that depend on it, have been disabled. AluraAPP.iOS.

I using Xamarin.form

I already reinstalled the visual studio and xamarin vs, but this error to be continued.

someone has gone through this error ??

i need help.

EntryRenderer - adding ellipsis

$
0
0

I have a custom renderer that derives from EntryRenderer. I need to be able to display the text input with an ellipse at the end if it exceeds the size of the entry control.

I've tried setting "SetSingleLine(true)" and the Ellipsize to Android.Text.TextUtils.TruncateAt.End.

This is not working - when I move to the next entry field, the EntryRenderer field still display the entered text with no ellipse. I can also only see the end of the entered text where I was expecting to see the start of the entered text with the end replaced with an ellipse.

Any help/pointers much appreciated.


Xamarin Forms and File access

$
0
0

I've been working on a Xamarin Forms App to run on Android and iOS and have previously created an IFileService interface and then implemented specific functions such as FileExists, Delete, ReadFile etc in a platform specific implementation of the Interface. This all works nicely but I keep seeing references to using System.IO and then using the File and Directory objects below that. This troubles me as I don't have these classes in the Forms implementation of System.IO...

I am doing file access correctly in Xamarin Forms by using an Interface or is there an easier / less platform specific solution?

Let's talk performance

$
0
0

As we continue to release performance focused features and fixes, and build processes around performance, I want to have a thread dedicated to those items.

Our public roadmap itemizes the feature work we are doing and planning to do, and items related to performance are tagged. In addition to that, we are building into our CI processes ways to measure and compare performance metrics. The goal is that with specific commits and builds we can get visibility to any impact on speed and memory usage.

One of the initiatives I'm spearheading is to populate a solution with UIs that are representative of your applications. To that end, I'm asking you to consider sharing those layouts with us. Perhaps the best way to gather them would be to open a repository and have you submit pull requests. I'll get working on that next and post details here.

Fast Renderers for Android are now merged and in nightly and will be our next pre-release. I hope some of you will take some time to test them out and report back here with your findings.

Convert UWP WriteableBitmap to XamarinForms Image

$
0
0

Hi,

is there a way to convert a UWP WriteableBitmap to a XamarinForms Image? Trying a simple convert ends up with "cannot implicitly convert type WriteableBitmap to Xamarin Forms Image".

Do I have to convert it before to a base64 string? Or how would you handle that?

thanks

Overlaying image with text

$
0
0

I've seen a few discussions on this but can't seem to get the answers to work! I have an application on iOS which displays a single image across the screen and then need to show 2 labels on the image. The idea is that the image is a background to show a flight from / to details so From details go on the left and To details go just right of centre to overlay the correct part of the image. My XAML is


<Grid.RowDefinitions>

</Grid.RowDefinitions>

                        <Grid VerticalOptions="Start">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>

                            <Label Margin="5" Text="Flight From" VerticalTextAlignment="Center" HorizontalTextAlignment="Start" Grid.Row="0" Grid.Column="0">

                            </Label>

                            <Label Text="Flight To" Margin="15" VerticalTextAlignment="Center" HorizontalTextAlignment="Start" Grid.Row="0" Grid.Column="1" />

                        </Grid>
                    </Grid>

I'm fairly new to XAML but my intention was to have a grid within a grid with both overlayed. So the image would be across the width of the screen with the second grid overlaid with 2 cells each with text on it - so the first text would be the 'From' flight details and the second would be the 'To' flight details. Unfortunately the above doesn't do this - firstly the flight details appear above the image which is odd and secondly the outer grid seems to have a lot of blank space after it. any thought or suggestions most welcome.

With "Ad-Hoc | iPhone" selected, the building process will hang forever

$
0
0

We could build and debug on simulator, but when we want to build an Ad-Hoc ipa, the building process will get stuck without output message.
I have tried to use Visual studio on windows & mac, Xamarin studio, the same problem.

Did anyone met the same problem?

Viewing all 89864 articles
Browse latest View live


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