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

ListView rendering problem on Android

$
0
0

Hi,

I'm working on Xamarin Forms solution with iOS and Android project. In this page, I'm showing list of measured coordinates in ListView with custom ViewCell that contains Circle shapes from XFShapeView nuget package. I have defined context actions to delete item from list, but there is a rendering bug on Android.

As seen on attached image, when I try to remove 3rd item from list, everything goes well on iOS. But on Android, Circle shapes from actual row dissapeared, and all rows below 3rd are rendered with incorrect color (which is binding from item attributes).

Any idea whats wrong?


Slider control as audio seekbar

$
0
0

Hi,
I'm writing a simple media player using Dependency services to play an mp3 file. While the sound is playing it updates a "slider" in the main forms window. everything works fine so far, now I just want the slider to pause the mp3 and then jump to the position that relates to where the user drags the slider, just like a normal seekbar but I can't find any information on how to pickup events from when the user interacts with the slider other then the "value changed event" that will be raised all the time since the code change this value from the player on each platform. Does someone know how tho get events from this user interaction with the slider?

Best Regards
/magnus

Master Detail Page - Status Bar Problem on Android

$
0
0

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

How it looks like

What I would like to achieve

Error inflating class android.support.v7.widget.Toolbar after updaring to v7.AppCompat Version 23.3

$
0
0

I am creating a Xamarin Forms Project and using android.support.v7.widget.Toolbar with FormsAppCompatActivity. The code I'm posting below was working with Xamarin.Android.Support.v7.AppCompat Version: 23.0.1.3

But after I upgraded to 23.3.0 this has started throwing Android.Views.InflateException: Binary XML file line #1: Error inflating class android.support.v7.widget.toolbar exception.

Here is my code for MainActivity

[Activity(Label = "AppMob.Client", Icon = "@drawable/icon", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
    public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
    {

        protected override void OnCreate(Bundle bundle)
        {
            FormsAppCompatActivity.ToolbarResource = Resource.Layout.toolbar;
            FormsAppCompatActivity.TabLayoutResource = Resource.Layout.tabs;

            base.OnCreate(bundle);

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

            Xamarin.FormsMaps.Init(this,bundle);
            GoogleAnalyticsHelper.GetGASInstance().Initialize_NativeGAS(Application.Context);  //For GA initialization
            LoadApplication(new App());
        }
}

This is my code for Resource.Layout.toolbar

    <?xml version="1.0" encoding="utf-8"?>
    <android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:minHeight="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
        app:layout_scrollFlags="scroll|enterAlways" />

Iconize plugin for Xamarin.Forms - Easily add icon fonts to your projects

why InputTransparent = true not working on Pages?

$
0
0

I am trying to create a transparent pop up page. when i set the InputTransparent = true in the page.cs file ,So when i touch the transparent page, the background pages not working.

Xlabs radio buttons are not appears in Windows phone emulator in xamarin forms

$
0
0

Hi guys,
i am working on xamarin forms,
Now i got a stuck to shows the radio buttons in windows phone,But android works fine. I used xlabs nuget package in my xamarin forms.

Why does the grid only appear after I exit and re-enter the app?

$
0
0

So I have in my App.cs a Mainpage that is set to a tabbedpage which is set to a child contentpage which has a grid with two buttons as part of the stacklayout.

When I first open the app the buttons are not visible, but when I open it again they appear.

The grid is initialised in the C#-code of the child contentpage like this:

var thegrid = new Grid();
thegrid.Children.Add(new Button { Text = "1" }, 0, 0);
thegrid.Children.Add(new Button { Text = "2" }, 1, 0);

And then later in the code used like this:

Content = new StackLayout
            {
                VerticalOptions = LayoutOptions.End,
                Padding = App.thepadding,
                Spacing = App.thespacing,
                Children =
                {
                    thegrid,
                    (other things here)
                }

What am I doing wrong? Thank you very much in advance for helping out.


Custom Renderer Link All Assemblies Problem

$
0
0

Hello I have one custom renderer for entry.

Everything is fine when the selected linker is "Link SDK Assemblies Only"

But when I choose "Link All Assemblies" it throws , on

InitializeComponent

Shortly it says ,

System.MissingMethodException
Default ctor not found for type my CustomRenderer.

I am using updated Xamarin ...193 and Xamarin Studio On Mac

BTW it was working and now it is not and on code nothing changed.

PCL Storage is not working

$
0
0

I'm using Xarmarin.fomrs, but I'm having trouble building an Android.

IOS build is succeeds.

PCL Storage is nuget package version.

code

    Task<IList<IFolder>> cur = FileSystem.Current.LocalStorage.GetFoldersAsync();

foreach (IFolder f in cur.Result)
{
    System.Diagnostics.Debug.WriteLine(f.Path.ToString());
}

Log

MonoDroid] UNHANDLED EXCEPTION:
[MonoDroid] System.NotImplementedException: This functionality is not implemented in the portable version of this assembly. You should reference the PCLStorage NuGet package from your main application project in order to reference the platform-specific implementation.
[MonoDroid] at PCLStorage.FileSystem.get_Current () [0x00013] in <7c72f0327d1949c3b4fa67daade24971>:0
[MonoDroid] at Sample_Xamarin.Sample_XamarinPage..ctor () [0x0000d] in /Users/woodgh/Projects/Sample_Xamarin/Sample_Xamarin/Sample_XamarinPage.xaml.cs:14
[MonoDroid] at Sample_Xamarin.App..ctor () [0x0000e] in /Users/woodgh/Projects/Sample_Xamarin/Sample_Xamarin/App.xaml.cs:12
[MonoDroid] at Sample_Xamarin.Droid.MainActivity.OnCreate (Android.OS.Bundle bundle) [0x00024] in /Users/woodgh/Projects/Sample_Xamarin/Droid/MainActivity.cs:25
[MonoDroid] at Android.Support.V4.App.FragmentActivity.n_OnCreate_Landroid_os_Bundle_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_savedInstanceState) [0x00011] in <27c17fe440cf491ba8255bcefade6e02>:0
[MonoDroid] at (wrapper dynamic-method) System.Object:7ba7ead9-4409-4e63-bde9-5185552e73f1 (intptr,intptr,intptr)

Refresh ListView when Switch in ListView has been Toggled

$
0
0

Hello community,

I'm new to the board and was wondering if someone of you could help me with the following problem.

I've got a ListView which has to be reloaded as soon as a Switch has been toggled.

Great would be something like this:

DataTemplate:

class ViewXOrFilterValue : ViewCell
    {


    public ViewXOrFilterValue(Action<string> funcUpdateList)
        {

        StackLayout CellWrapper = new StackLayout()
        {
            Orientation = StackOrientation.Horizontal,
            HorizontalOptions = LayoutOptions.FillAndExpand
        };

        Switch sw = new Switch()
        {
            HorizontalOptions = LayoutOptions.EndAndExpand,
        };

        sw.Toggled += (object sender, ToggledEventArgs e) => {

                funcUpdateList("test123123");

            };

        CellWrapper.Children.Add(sw);

        View = CellWrapper;

    }

}

And then somewhat like

 ...
 tpXOrFilterValueList.ItemTemplate = new DataTemplate(typeof(views.filter.ViewXOrFilterValue(OWN_METHOD_WHICH_TRIGGERS_RELOAD_OF_LIST)));
 tpXOrFilterValueList.ItemsSource = maOrgSelectableValues.ToArray();
 ...

to set the Template and the Source. But I dont know if its even possible to add parameters to DataTemplates?

I also tried to work with Command Bindings as described here: https://blog.xamarin.com/simplifying-events-with-commanding/

The whole thing works basiaclly but in the end the command which I was binding is always null:

void OnSwitchToggled(object sender, ToggledEventArgs e)
    {
        if (Command == null)
        {
            System.Diagnostics.Debug.WriteLine("Command is null!");
            return;
        }


        System.Diagnostics.Debug.WriteLine("EXECUTING calling method....!");

        object parameter = Converter.Convert(e, typeof(object), null, null);

        if (Command.CanExecute(""))
        {
            System.Diagnostics.Debug.WriteLine("Executing..");

            Command.Execute("");
        }
        else
        {

            System.Diagnostics.Debug.WriteLine("Not able to execute!");

        }
    }

The code for preparing item source / binding is the following:

...

            maOrgSelectableValues = new List<DialogXOrValue>();

            foreach (var oVal in filter._aValues)
            {
                DialogXOrValue oXorVal = new DialogXOrValue();
                oXorVal._bSelectable = oVal._bSelectable;
                oXorVal._bSelected = oVal._bSelected;
                oXorVal._iSort = oVal._iSort;
                oXorVal._sText = oVal._sText;
                oXorVal._sValue = oVal._sValue;
                oXorVal.methListViewUpdate = new Command<string>(reloadFilterList);


                oXorVal.bIsVisible = true;

                maOrgSelectableValues.Add(oXorVal);

            }

...

            tpXOrFilterValueList.ItemTemplate = new DataTemplate(typeof(views.filter.ViewXOrFilterValue));
            tpXOrFilterValueList.ItemsSource = maOrgSelectableValues.ToArray();
...

And the Binding in the Cell:

...

            ViewXOrFilterValueSwitchToggleBehavior oBehaviour = new ViewXOrFilterValueSwitchToggleBehavior();
            oBehaviour.SetBinding(ViewXOrFilterValueSwitchToggleBehavior.CommandProperty, "methListViewUpdate");
            // oBehaviour.SetBinding(ViewXOrFilterValueSwitchToggleBehavior.InputConverterProperty,

            sw.Behaviors.Add(oBehaviour);

...

I think the binding of the command is not working because I'm trying to bind it to the switch element?!

Did someone of you had a similar problem?

I'd be happy about any help!

Thanks in advance,

Alex

Get coordinates of user touch on an image / SkiaSharp

$
0
0

Hi,

Sorry about my english, i will try to divide what i need in some topics to become more understandable:

* Get coordinates of user touch on an image;
* Use this coordinates to draw on the image based on the touchs;

I was trying to do this using Mr.Gestures and SkiaSharp but i was not able to make my code works.
I don't know if i have to put the image into some container layout and firing the tap event from this container.

Have someone already worked with this two libraries together?

Thanks in advance.

What is RenderWith?

How to inject sqliteconnection in Repository generic use Autofac?

$
0
0

public interface IRepository where T : class, new()
{
Task<List> Get();
Task Get(int id);
Task<List> Get(Expression<Func<T, bool>> predicate = null, Expression<Func<T, TValue>> orderBy = null);
Task Get(Expression<Func<T, bool>> predicate);
AsyncTableQuery AsQueryable();
Task Insert(T entity);
Task Update(T entity);
Task Delete(T entity);
}

public class Repository<T> : IRepository<T> where T : new()
{
    private SQLiteAsyncConnection db;

    public Repository(SQLiteAsyncConnection db)
    {
        this.db = db;
    }

    public AsyncTableQuery<T> AsQueryable() =>
        db.Table<T>();

    public async Task<List<T>> Get() =>
        await db.Table<T>().ToListAsync();

    public async Task<List<T>> Get<TValue>(Expression<Func<T, bool>> predicate = null, Expression<Func<T, TValue>> orderBy = null)
    {
        var query = db.Table<T>();

        if (predicate != null)
            query = query.Where(predicate);

        if (orderBy != null)
            query = query.OrderBy<TValue>(orderBy);

        return await query.ToListAsync();
    }

    public async Task<T> Get(int id) =>
         await db.FindAsync<T>(id);

    public async Task<T> Get(Expression<Func<T, bool>> predicate) =>
        await db.FindAsync<T>(predicate);

    public async Task<int> Insert(T entity) =>
         await db.InsertAsync(entity);

    public async Task<int> Update(T entity) =>
         await db.UpdateAsync(entity);

    public async Task<int> Delete(T entity) =>
         await db.DeleteAsync(entity);
}

Forms Previewer - 'An exception occurred while rendering the control'

$
0
0

With Visual Studio 2017 (latest rc) - after opening xaml previewer, I am presented with error in the designer 'an exception occurred while rendering the control'. This occurs while trying to view the Android view. I can however view the ios view when my mac build agent is available.

If I click the (!) icon i see a series of exception messages

i.e.
you must call xamarin.forms.init prior to using it
at xamarin.forms.device.get_info()

etc.


Binding Dataset to new page

$
0
0

Hello,

I have a Listview on mainpage, filled with items. After clicking an item , a query uses the item.iD to start a query against a table in SQLite and retrieves exactly 1 row with Details for that item.
So far, so good.
I want to bind this Dataset (1 row) to a new page, to show the Details.
If all Details of the items were on mainpage, binding would be easy, like so:

    public async void OnListItemClicked(object sender, SelectedItemChangedEventArgs e)
        {
 if (item.xKontext == "OPS")
        {
        var item = e.SelectedItem as IndexItem;
        var secondPage = new DetailPage.Detail_OPS();
            secondPage.BindingContext = item;
            await Navigation.PushAsync(secondPage);
    }
   }

..but the items of mainpage have different data structures for their details, depending of their [item.xKontext ]

How can i set the BindingContext of the secondPage, using the recordset of the following...?
Maybe i should not use a List to store the outcome of the SQL?

public async Task<List> GetICD_Detail_Async(string strFilter)
{
List vICD = await dbConn.QueryAsync(
"SELECT * FROM t200_Details_ICD WHERE xQuelleID = '" + strFilter + "'");
return vICD;
}

Regards
Christoph

System.IO.Compression It does not work - Microsoft.Bcl.Compression

$
0
0

I've a xamarin form project, when i use this code
...
var re =await client.Execute(request);
var gs = new GZipStream(new MemoryStream(re.RawBytes), System.IO.Compression.CompressionMode.Decompress);
..

to call a web api service that return a compress GZipStream json but xamarin studio debug return me this
"The underlying implementation for System.IO.Compression.dll could not be loaded. Make sure to add a reference to the Microsoft.Bcl.Compression NuGet package from your main application project."

but in my project i've Microsoft.Bcl.Compression and i use FubarCoder.RestSharp.Portable

How can i risolve this problem ?

Thanks
Alex

HTML Editor Control availablity for Xamarin.Forms

$
0
0

Hi all,
Is there a readily available HTML Editor Control available to be used in Xamarin.Forms? We need to Have HTML Edit capabilities on a mobile application of ours.

Thanks, regards

Jörg Fischer

ScrollView inside a Grid with Starred Row Definitions

$
0
0

Hi!
I'm trying to create a vertical scrollable Grid. So I've put my Grid inside a ScrollView.
Now, I know everything would work just fine if every row was defined with Auto or Absolute GridUnitType, but I really need to split my Grid into starrable rows (except for one auto-width row), proportioning each row height.
Is there a way to make a grid with starred row definitions scrollable? Or maybe someone has found a workaround to simulate this behaviour?
Thanks,
Jacopo

Android Emulator slowed down, not deploying app

$
0
0

Hello,

I am having some issues with getting the Android Emulator to display my program. I am using the most current update of Xamarin Studio and am using it with Mac OS Sierra v. 10.12.3. I typically run my application using ProjectName.Droid —> Debug with the Android Accelerated x86 version of the emulator. It ran normally before I committed some new code from GitHub. Now, the emulator is “stuck” on the generic Android screen and is taking an extremely long time to load—the longest I’ve had it run in this situation is about 20 minutes and it was still loading. Any tips to make the emulator run at its faster, original speed? Any help would be appreciated.

Viewing all 91519 articles
Browse latest View live