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

Editor view - How to configure

$
0
0

Hi,

I need a multi line text input, and an Editor is suitable.

When I use it like

Editor edit = new Editor();

I get a text input which shows only 1 line.

And when I create multiple lines, save the text, later create on another page an Editor and pass the multi line text into it like

edit.Text = myText;

when the page shows up, the Editor occupies that much space so that all lines are visible. That is not desired. The editors should remain showing only that much lines at a time the user specify, when the text is larger the user must scroll.

How is scrolling within the Editor done? I swipe, but that doesn't seem to be the right way, and also no scroolbar is visible. To mention, the Editor is on a scroolable page with other views (Buttons, etc.).

How to create an Editor, and configure it, so that it shows perhaps 2 or 3 or so lines?

How to avoid the Editor becoming larger, when a longer multiple line text is passed into it programmatically?

That usually must be easy, but couldn't find any useful informations.

Cheers


Bug? Image and Color Binding.

$
0
0

Issue:
Binding Image in Forms and change by tap gesture may fail to load image. No Crash, just not showing Image.
Binding Color in Forms and change by tap gesture may crash, java null reference, crashed in BindingExpress.cs, I can't see which step it crashed.

Project:
A page with 10 small images with tap gesture attached for working as selectable button. When selected, change background color.
A static class working as repository for default Image (For testing purpose, I'm using only one image) and Colors.
Testing on Android, don't have access to other platforms at the moment.

Repro Steps:
Image Issue, when load, random number of buttons load without image.
Color issue, when page first load and button clicked, change background color works fine.
When page 2nd load and button clicked, change background color crash at BindingExpress.cs when setting a default Color from repository.

I'm a kind of beginner in Xamarin, so, ways of debug to see exactly why go wrong, how to work around the issue, etc. Greatly appreciated.

I have posted another thread before about the image binding. I'm still looking for answers.
https://forums.xamarin.com/discussion/74441/workingwithimages-bug-not-supported-feature-or-im-doing-it-wrong

Thanks in advance.

WebView.Eval not call javascript function inside my HTML

$
0
0

Hi guys, I'm trying to use the Eval function of the WebView control to run a javascript function into my WebView. The WebView loaded correctly my HTML with the Javascript function, but when I use WebView.Eval(javascript_function), nothing happens and the function is not called.
Here my CS code:

 var _Script = string.Format("enableBeacon(\"{0}\") ", id);
            _WebViewMap.Eval(_Script);

Here my Xaml:

<StackLayout VerticalOptions="Center" HorizontalOptions="Center">
<WebView x:Name="WebViewMap" WidthRequest="1000" HeightRequest="1000" Source="{Binding HtmlSource.HtmlUrlSource}"/> 
</StackLayout>

Here my Javascript function:

 function enableBeacon(id)
 {
     var myBeacon = document.getElementById(id);
     myBeacon.style.display = "";
    alert("I am an alert box!");
 }

Thanks in advance

how do we implement a radio button group in xamarin forms for windows 8.1?

$
0
0

I could't found a control for radio button group in xamarin forms

Save User Settings ( switch Toggles ) Xamarin forms

$
0
0

Lets say we have a page in PCL xamarin forms application I want to save the settings ( toggle switch choices ) for each users (see attachement) :

  • save them locally (to load settings on user logging in )and remotly ( remotly for treating each user (with a web application ) depending on the choices he picked )
  • should I load those settings from local each time a user log in ??

Async method that calls in ViewModel causes deadlock

$
0
0

I do requests to Github Api so I have async methods, these do this job. Before it, I always called they in method, that calls from command(actually DelegateCommand). But now I wanna do request in ViewModel because I need to display list on page. I am using Prism to wire view and viewmodel.
Because I can't make viewmodel async, I can't use await word, so I tried to do something like gets result from task, or task.wait. But with this I have the same result. My app stop works with white display when it did request. I read some info about that and I understood that call async method in not async method is bad, and it causes deadlock, but I don't know what to do with this. And I think deadlock causes that app stop works.
Here is method where app die:

 public async Task<IEnumerable<RepositoryModel>> GetRepositoriesAsync()
        {
            try
            {
                    var reposRequest = new RepositoryRequest { Sort = RepositorySort.FullName };
                    var gitHubRepos = await _gitHubClient.Repository.GetAllForCurrent(reposRequest);  //async request, don't say about name convention, it is not my method.
                        var gitRemoteRepos = new List<RepositoryModel>();

                        foreach ( var repository in gitHubRepos )
                        {
                            var repos = new RepositoryModel();
                            repos.RepositoryTypeIcon = GetRepositoryTypeIcon(repository);
                            gitRemoteRepos.Add(repos);
                        }

                        return gitRemoteRepos;
                    }
                    catch ( WebException ex )
                    {
                        throw new Exception("Something wrong with internet connection, try to On Internet " + ex.Message);
                    }
                    catch ( Exception ex )
                    {
                        throw new Exception("Getting repos from github failed! " + ex.Message);
                    }
                }

And here is viewmodel:

public class RepositoriesPageViewModel : BindableBase
    {
        private INavigationService _navigationService;
        private readonly Session _session;
        public ObservableCollection<RepositoryModel> Repositories { get; }
        private readonly RepositoriesManager _repositoriesManager;

        public RepositoriesPageViewModel(INavigationService navigationService, ISecuredDataProvider securedDataProvider)
        {
            _navigationService = navigationService;

            var token = securedDataProvider.Retreive(ConstantsService.ProviderName, UserManager.GetLastUser());
            _session = new Session(UserManager.GetLastUser(), token.Properties.First().Value);
            var navigationParameters = new NavigationParameters { { "Session", _session } };

            _repositoriesManager = new RepositoriesManager(_session);

            var task = _repositoriesManager.GetRepositoriesAsync();
            //task.Wait();
            Repositories = task.Result as ObservableCollection<RepositoryModel>;

        }


    }

Android: weird Exceptions (Cache?)

$
0
0

I deleted a ContentPage and created a new one with same name.
Now, when I run Example Code where the old Page was pushed, I get a ClassCastException (Cannont cast android.widget.imageview to viewgroup).

This is the Example Code

await Parent.Navigation.PushAsync(new CarouselPage
            {
                Children = {
                    new ContentPage{
                        Content = new ContentView{
                            BackgroundColor = Color.Red
                        }
                    },
                    new ContentPage{
                        Content = new ContentView{
                            BackgroundColor = Color.Green
                        }
                    }
                }
            }, true);

I restarted the phone (Galaxy S6 Edge), deleted the App manually, restarted my Computer (Mac), deleted Bin/Obj.
But still I get this Exception... (Btw. when I run this example in a fresh App, it´s working).
What else can I try?

Xamarin Forms startup times are unusably slow

$
0
0

My startup screen shows two buttons and a label in a StackLayout, and does nothing more. I've timed the app to take 2.5~3.0 seconds just to show that screen, in Release mode, on an actual device (Motorola Mini XT1030). That's an absurd and unacceptable amount of time to show nothing to the user. As far as I can tell, there's no way to show a splash-screen during that initial loading.

Yes, I'm using [assembly: XamlCompilation(XamlCompilationOptions.Compile)] (without it startup times are around 4.2s!). Running Xamarin Profiler, I see that 100% of the startup code is out of my control.

Is there anything else I can do to speed up my startup times? Or is Xamarin Forms really still not production-ready, and I should start recreating all my UIs on every platform?


find key presses from layout controls (not entry field) in xamarin.forms

$
0
0

Hi,

I need to find what key the user pressed on a keyboard using xamarin.forms, ideally inside an AbsoluteLayout. I've come up with a few ways myself, but can't get any of them working.

As there isn't an event for this on the AbsoluteLayout control, i tried a little cheat, which was putting an entry field (textbox) on the screen, but hiding it above, so it can't be seen and using the result form that, but it loses focus when someone presses the screen or a button on the screen. so i tried adding an event to each button which refocuses the textbox once i've handled the press and this seemed ok at first, however, if they press anywhere else on the screen, it also loses focus.

I also tried adding a TapGestureRecognizer to the screen, and focusing the button when they press anywhere on the screen, however, there were 2 issues with this, the first being that it appears to only fire when something inside it is touched, and secondly, when i call the focus method for the second time (if they click the screen twice) it un-focuses the entry field, even if i check "isfocused" first (think this is a bug).

I'm only concerned about windows 8 and android apps so far. iOS may come later, but for now im just trying to get it working for these OS's. so maybe i could code it in the windows and android projects (inside my shared project solution), however, i have absolutely no idea where to even begin doing that. I mean, if this is the best way, how can i pass my AbsoluteLayout to the windows project and get it to know what it is, and convert it into a control which i can then add the event to.

Any help or advice, or ideas would be much appreciated. I cant find anything in NuGet which will help me with this. Any ideas?

Many thanks
James

How can I add icon on ActionBar?

$
0
0

I want to add an Icon on the ActionBar in my Xamarin forms project..........Please help me Thank you

Record audio within Xamarin to send to Cloud Speech API from Google

$
0
0

I am writing a cross-platform app (Android, iOS and Windows (Universal)) with Xamarin.Forms. Within this app i am trying to implement speech-to-text in the Dutch language, but have no success as of yet. Because all the standard voice recognition in Xamarin don't work for the Dutch language (like API.ai).

I came across the Cloud Speech API from Google that supports many languages including the Dutch language, so i am trying to implement the Cloud Speech API but i need to record audio in Xamarin and then send it to the API. (I have a demo of the API working with audio samples)

For using the Cloud Speech API I need to record audio files within Xamarin to send to the API. I have tried using Xamarin.Forms to record audio (files), but within Xamarin i could only find a way to record audio using Xamarin.Android and Xamarin.iOS. I have not found a way as of jet to record audio using Xamarin.Forms on the Windows platform. I know i will probably need a variation on the DependencyService, however i would not know how to record audio on the Windows (UWP) platform within Xamarin.forms

So my question is: does someone have a idea to implement audio recording within Xamarin.Forms (specific Windows Universal)?

i found a similar StackOverflow question, but yet a little different.

Or if there is another way to record audio within Xamarin. (I have tried using a WebView within Xamarin to access a WebPage with HTML5 and JavaScript to record audio. this script works on a mobile webbrowser (chrome and firefox), but once i go to the script with a WebView it gives a error that the microphone is not accessable).

Michael

Global styles in App.Xaml resources not being applied in Prism app

$
0
0

HI,

I have defined some global styles in the App.Xaml resources as follows:

<prism:PrismApplication xmlns="http://xamarin.com/schemas/2014/forms" 
        xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
        xmlns:prism="clr-namespace:Prism.Unity;assembly=Prism.Unity.Forms" 
        x:Class="MyApp.App">
    <Application.Resources>
        <ResourceDictionary>
    <Style TargetType="Grid">
        <Setter Property="RowSpacing" Value="0" />
        <Setter Property="ColumnSpacing" Value="0" />
        <Setter Property="Padding" Value="0" />
    </Style>
        </ResourceDictionary>
    </Application.Resources>
</prism:PrismApplication>

However, this style is never being applied to any of the Grids on my ContentPages, could someone please let me know what I'm doing wrong? I am calling the App/InitializeComponent() method before the MainPage is created which seemed to be the issue with other developers. I'm using v.6.2.0 of the Prism package.

Many thanks.

System.TypeLoadException On Bindable Property

$
0
0

Hi I am getting this error:

Could not load type 'Xamarin.Forms.ElementTemplate' from assembly 'Xamarin.Forms.Core, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'.

on a bindable property for a data template

public static readonly BindableProperty ItemDetailTemplateProperty =
        BindableProperty.Create<Accordion, DataTemplate>(p => p.ItemDetailTemplate, default(DataTemplate)
            , BindingMode.TwoWay, null, ItemDetailTemplateChanged);

    public DataTemplate ItemDetailTemplate
    {
        get { return (DataTemplate)GetValue(ItemDetailTemplateProperty); }
        set { SetValue(ItemDetailTemplateProperty, value); }
    }

    private static void ItemDetailTemplateChanged(BindableObject bindable, DataTemplate oldvalue, DataTemplate newvalue)
    {
        var accordionView = bindable as Accordion;
        if (accordionView == null) return;

            accordionView.CreateDetailView();

    }

private void CreateDetailView()
    {
        var itemDetail = ItemDetailTemplate.CreateContent() as View;

        _detailView = new ScrollView
        {
            Content = itemDetail
        };
    }

it happens on accordionView.CreateDetailView

Thanks

How to implement a popup window in listview

$
0
0

Hi,

I am working in xamarin.forms. In one page there is a list of items(implemented using list view). And while clicking on particular item i need to get a popup window. Please give me a solution.

Xamarin forms Entry / binding bug on Android 7

$
0
0

Android 7 / XF has a problem with some combination of Entry fields, binding, keyboards. I haven't figured out exactly what is the root cause. It came to my attention after upgrading my personal phone to Android 7 and testing an app I'm working on.

I have this problem in a complex app but please see the reproduction of this bug I have posted here : https://github.com/rossjempson/XFEntryBindingBug

Basically, after editing the 'Receiver's Name' entry field, and then editing the 'Receiver's Email', the data being entered into the email field appears visually (and in the associated viewmodel) against the 'Receiver's Name'.

Also, I've noticed the wrong keyboard is displayed when editing the email field, it should be the email keyboard but after flashing up reverts to the default keyboard from the first field.

It works fine when deployed to a Android 6 device, but a physical device and an emulator running Android 7 both have the same problem.

In the attached image, I typed 'Ross' in the 'Receiver's name', then I typed 'ross@gmail.com' into the 'Receiver's email' entry field but the data is bound to the first field.


Orientations – What about upside down?

$
0
0

Apologies for what feels like a newbie question, but could anybody confirm for me please what is expected/possible when iOS, Android and Windows Phones are rotated to be upside down?

I believe (but am not sure) that Windows Phone simply does not support upside-down. It that correct?
iOS looks like it should support upside down, but I have selected Upside Down as a Supported Device Orientation in info.plist but it still does not work. Has anybody else had success with this?
I cannot see anything within an Android project that allows specification of upside-down being supported. Is that the case?

I am using Xamarin.Forms 1.3.2.

Many thanks,

John H.

Is Native Embedding The Same As A Renderer?

$
0
0

I am trying to work around an XF bug in the ListView. I read about "Native Embedding" controls. Is there any difference between that and using a renderer? For instance a ListViewRenderer.

Thanks

Picker - Change placeholder text color ( XF iOS )

$
0
0

I'm trying to change the placeholder text color for the Picker control in Xamarin Forms for iOS.
With Android we can access this through a custom renderer, but for iOS there doesn't seem to be any hooks.

Am I missing something?

MasterDetailPage - Change Detail in the current Detail Page?

$
0
0

Hey,

how can I change the Detail Element from MasterDetailPage in the codebehind of the actual DetailPage?
E.g. I want to set a new DetailPage when the user clicks on an Image in the DetailPage.

Back button on navigation bar root page

$
0
0

The app that I am developing contains a single web view and a navigation bar. Navigation buttons should allow the user to revisit previous pages. The problem that I have is that since it is a single page app, the back button doesn't appear. How can I enable the navigation button on the root page?

Viewing all 81910 articles
Browse latest View live


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