Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all 204402 articles
Browse latest View live

How to add the seperator in Xamarin forms.

$
0
0

How to add the seperator in Xamarin forms ?


Xamarin forms use native platform specific controls.

$
0
0

In my Xamarin forms App I want to show platform specific controls Spinner in Android and Segmented Control in iOS. I have written the custom view(Derived from Xamarin Forms View) and platform specific renderers(ViewRenderer). For Android in "OnElementChanged" method I am setting Spinner view. But it ends in following exception:

Java.Lang.RuntimeException: Binary XML file line #19: You must supply a layout_height attribute.

I tried to set LayoutParams but it's not working.

Code:
XAML:
StackLayout HorizontalOptions="FillAndExpand" VerticalOptions="Center" BackgroundColor="Aqua"
local:CustomGradeView HorizontalOptions="Fill" VerticalOptions="Fill"
StackLayout

public class CustomGradeView : View{}

public class CustomGradeRenderer : ViewRenderer
    {
        Spinner spinnerView;

        protected override void OnElementChanged (ElementChangedEventArgs<Xamarin.Forms.View> e)
        {
            base.OnElementChanged (e);

            // SetNativeControl (new TextView(Context){Text="Test for renderer"}); Working fine, no issues.

            spinnerView = new Spinner (Context);
            spinnerView.LayoutParameters = new LayoutParams (100, 100);
            ArrayAdapter<string> spinnerAdapter =
                new ArrayAdapter<string> (Context, Resource.Layout.support_simple_spinner_dropdown_item, grades);
            spinnerView.Adapter = spinnerAdapter;
            SetNativeControl (spinnerView); // Exception
        }
    }

Xamarin: extract android sqlite to a local folder on the device

$
0
0

Dear all,
I need to export my android sqlite database to a folder on my memory so I can get access to it outside my mobile.
example of use : " I need to take a backup of my database and see what does it contain."
I searched the web and did not found any Xamarin method that works .
anyone have an idea about how to do this?

DefaultRequestHeaders is null in xamarin.forms for iOS and android

$
0
0

I am using the following code and DefaultRequestHeaders is coming as null incase of iOS and android where as working properly in windows device.

NetworkCredential proxyCreds = new NetworkCredential(username, password, doamin);
HttpClientHandler handler = new HttpClientHandler();
handler.Credentials = proxyCreds;
System.Net.Http.HttpClient client = new System.Net.Http.HttpClient(handler);
client.BaseAddress = new System.Uri("http://sharepointURL:80/qwe/asd/");
string cmd = "_api/contextinfo";
client.DefaultRequestHeaders.Add("Accept", "application/json;odata=verbose");
client.DefaultRequestHeaders.Add("ContentType", "application/json");
client.DefaultRequestHeaders.Add("ContentLength", "0");
StringContent httpContent = new StringContent(string.Empty);

invalid cast exception when I point an IValueCallback implemented class

$
0
0

public class MainActivity : Activity
{
WebView wt;
static TextView tv;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Set our view from the "main" layout resource

        SetContentView(Resource.Layout.Main);
        wt = FindViewById<WebView>(Resource.Id.webView1);
        wt.Settings.JavaScriptEnabled = true;
        tv = FindViewById<TextView>(Resource.Id.textView1);
        wt.SetWebViewClient(new wvc());
        wt.LoadUrl("http://www.weatheronline.co.uk/Turkey/Antalya.htm");
    }
    class wvc : WebViewClient
    {
        public override void OnPageFinished(WebView view, string url)
        {
            view.EvaluateJavascript("document.getElementsByClassName('Temp_minus')[0].innerText;", new result());
        }
    }
    class result : IValueCallback
    {
        public void OnReceiveValue(Java.Lang.Object value)
        {
            tv.Text = value.ToString();
        }
    }

I get the exception in the title on

view.EvaluateJavascript("document.getElementsByClassName('Temp_minus')[0].innerText;", new result());

the problem is, I can't seem to find my mistake.

UpdateSourceTrigger

$
0
0

I would like to know if in Xamarin.Forms it is also possible to modify two-way binding with the “UpdateSourceTrigger”option like in WPF, where it is possible to specify a bound attribute for example like this:

Text="{Binding StringData, Mode=TwoWay, UpdateSourceTrigger=Explicit}"

I just found this unanswered question:

https://forums.xamarin.com/discussion/28077/having-an-issue-with-a-binding-is-there-an-equivalent-to-updatesourcetrigger-somewhere

Does anyone know whether and how this is implemented in Xamarin.Forms?

EditText.TextChanged error

$
0
0

Hi.
I'm making an app and I've encountered a problem with the TextChanged and AfterTextChanged events of EditText views.
I start by initializing the Text to a value and then add an eventhandler to TextChanged or AfterTextChanged.
The problem happens when i try to write something new in the EditText. If i write a new number the TextChanged event will fire twice, and the first time the Text property of my EditText will contain an empty string, even though the EditText is not empty. Then the event fires against and this time the ET contains what i expect.
I've added an if statement to check if it's an empty string, but this is just a temporary fix that won't work because then the user can't change the ET to being empty.
This is my code:

EditText editNum= FindViewById<EditText>(Resource.Id.editNum);
editNum.Text = SessionVars.numValue;    //SessionVars is my static data container
editNum.TextChanged += (sender, e) =>
{
    if (editNum.Text != "") //Breakpoint here
    {
        int value;
        if (int.TryParse(editNum.Text, out value))
            SessionVars.numValue = value;
        else
        {
            Toast.MakeText(this, "Num has to be an int.", ToastLength.Long).Show();
            editNum.Text = SessionVars.numValue;
        }
    }
};

Am i doing something wrong or is it a bug?

How to Identify event types ?

$
0
0

After exposing my action to C# code I am able to create the following code:

partial void pictureBox1_actions(NSObject sender)
{

}

this works fine on left click but what if I want to track other activities of Mouse. Like I Want to perform an action on left click. How can I achieve this?


How to generate .IPA file

$
0
0

Hi,
How to generate .ipa file in xamarin forms in Visual Studio..

Thanks
Lucy

Intellisense problem in Visual Studio

$
0
0

Hi there, I am runing my latest stable version of Xamarin on VisualStudio2015 update1 on windows 10, and I noticed some youtube video showed that they had intellisense in VS, which made me confused. The intellisense seems not working in my VS, and I did download an extension from vs gallary but it still did not work. Do I need to setup something?
Thanks for help

Usage in Visual Studio 2015 Unit Test Project

$
0
0

Hi. I created an x64 console application in VS2015 to try out the SkiaSharp nugget package. No problem.

But if I create a unit test project, the simplest of tests using SkiaSharp causes an exception. The message shown in the test result pane is

Test Outcome: Failed
Test Duration: 0:00:00.0388023

Result StackTrace:
at SkiaSharp.SkiaApi.sk_filestream_new(String path)
at SkiaSharp.SKFileStream..ctor(String path)
at SkiaSharp.SKBitmap.Decode(String filename)
at BCA.Imaging.ImageHelper.TestSaveScaledImage() in C:\Users\Mike\Documents\Visual Studio 2015\Projects\ImagingLibrariesEvaluation\Imaging\ImageHelper.cs:line 15
at ImagingUnitTest.ImagingUnitTests.TestSkiaConcurrency() in C:\Users\Mike\Documents\Visual Studio 2015\Projects\ImagingLibrariesEvaluation\ImagingUnitTest\ImagingUnitTests.cs:line 33
Result Message:
Test method ImagingUnitTest.ImagingUnitTests.TestSkiaConcurrency threw exception:
System.DllNotFoundException: Unable to load DLL 'libSkiaSharp.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

although the output of the Tests window is slightly different:
------ Run test started ------
System.ArgumentNullException: Value cannot be null.
at System.Threading.Monitor.ReliableEnter(Object obj, Boolean& lockTaken)
at SkiaSharp.SKObject.Dispose(Boolean disposing)
at SkiaSharp.SKFileStream.Dispose(Boolean disposing)
at SkiaSharp.SKNativeObject.Finalize()
at System.Threading.Monitor.ReliableEnter(Object obj, Boolean& lockTaken)
at SkiaSharp.SKObject.Dispose(Boolean disposing)
at SkiaSharp.SKFileStream.Dispose(Boolean disposing)
at SkiaSharp.SKNativeObject.Finalize()
========== Run test finished: 1 run (0:00:00.2200161) ==========

Do you know of any workaround? I really need to get a unit test project up and running to convince my manager (and demonstrably so) that SkiaSharp is going to be reliable in a multithreaded environment, for example ASP.Net.

Thanks

Crash in native code Android 6

$
0
0

Hello,
we are getting crashes with Android 6.0.
Thanks for help
Jan Rosa


Build fingerprint: 'samsung/heroltexx/herolte:6.0.1/MMB29K/G930FXXU1BPLM:user/release-keys'
Revision: '8'
ABI: 'arm64'
pid: 14278, tid: 14351, name: Threadpool work >>> cz.freshflow.app <<<
signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
Abort message: '* Assertion at /Users/builder/data/lanes/3511/77cb8568/source/mono/mono/mini/mini-arm64.c:937, condition `arm_is_bl_disp ((code), (target))' not met
'
x0 0000000000000000 x1 000000000000380f x2 0000000000000006 x3 0000000000000000
x4 0000000000000000 x5 0000000000000001 x6 0000000000000000 x7 0000000000000000
x8 0000000000000083 x9 fefefefefefefeff x10 7f7f7f7f7f7f7f7f x11 0101010101010101
x12 0000000000000028 x13 0000007f870daf9c x14 0000000000000001 x15 0000000000000001
x16 0000007fa605d568 x17 0000007fa5ff03b8 x18 0000007fa63fd720 x19 0000007f870de500
x20 0000007f870de440 x21 0000000000000002 x22 0000000000000006 x23 0000007f7f7f4490
x24 0000007f86af2abc x25 0000007f85ce2d40 x26 0000007f8b197000 x27 0000000000000000
x28 0000000000000007 x29 0000007f870daf40 x30 0000007fa5fedb54
sp 0000007f870daf40 pc 0000007fa5ff03c0 pstate 0000000020000000

backtrace:
#00 pc 00000000000693c0 /system/lib64/libc.so (tgkill+8)
#01 pc 0000000000066b50 /system/lib64/libc.so (pthread_kill+68)
#02 pc 0000000000023990 /system/lib64/libc.so (raise+28)
#03 pc 000000000001e2c0 /system/lib64/libc.so (abort+60)
#04 pc 000000000021e1b0 /data/app/cz.freshflow.app-1/lib/arm64/libmonosgen-2.0.so

How to create user control in Xamarin.Android

$
0
0

How to create user control in xamarin.Android

Problem with prism modules and dependency injection on iOS if using "Link All" - can anybody help?

$
0
0

Hello,

I am using the modules of prism.

On Android, Win8.1, WinPhone8.1 and UWP the app works fine.

On iPhone Simulator too.

If I want to start the app on a real iPhone (Device) I must change the "Linker Options" of the ios-project to "Link all assemblies". Next step was to preserve some dlls from linking:
--linkskip=Microsoft.Practices.Unity --linkskip=Prism --linkskip=Prism.Unity.Forms --linkskip=Prism.Forms --linkskip=Microsoft.Practices.ServiceLocation

Now the application throws this error:

Microsoft.Practices.Unity.ResolutionFailedException: Resolution of the dependency failed, type = "Dvb.MobileCatalog.Module.KatalogPages.KatalogPagesModul", name = "(none)".

Exception occurred while: while resolving.

Exception is: InvalidOperationException - The type KatalogPagesModul does not have an accessible constructor.


At the time of the exception, the container was:

Resolving Dvb.MobileCatalog.Module.KatalogPages.KatalogPagesModul,(none)

I think, the app can not resolve the dependecy-injection I use in KatalogPagesModul (as shown in the examples from prism):

    public class KatalogPagesModul : IModule
    {
        private readonly IUnityContainer _unityContainer;

        public KatalogPagesModul(IUnityContainer unityContainer)
        {
            this._unityContainer = unityContainer;
        }

        public void Initialize()
        {
            _unityContainer.RegisterTypeForNavigation<HomePage>(PageNames.HomePage);
            _unityContainer.RegisterTypeForNavigation<KatalogPage>(PageNames.KatalogPage);
            _unityContainer.RegisterTypeForNavigation<ArtikelListePage>(PageNames.ArtikelListePage);
        }

    }

Can anybody help me to solve the problem?

binding 2 aar files

$
0
0

Hi guys,

Ok i've been struggling with this for a while now and i think i already have tried out a lot of possible solutions maybe i've done one of them wrong but i'm out of ideas now. So i'm hoping one of you could help me out here.

I've a project where i wan't to detect beacons those of Lightcurb. They have provide 2 .aar files, i already have an android bindings library project setup with those 2 files with build action libraryprojectzip (as the docs of xamarin told me to). the lighcurbsdk.aar depends on the androidibeaconlibrary.aar. as you can see in the image it cannot find the monitornotifier, rangenotifier etc.

so here is my metadata.xml:

<metadata>
  <add-node path="/api/package/class[implements[@name='java.util.Comparator']]">
    <method name="compare" return="int" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public">
      <parameter name="o1" type="java.lang.Object" />
      <parameter name="o2" type="java.lang.Object" />
    </method>
  </add-node>

<add-node path="/api/package[@name='com.radiusnetworks.ibeacon']/interface[@name='MonitorNotifier']"></add-node>

  <remove-node path="/api/package[@name='com.lightcurb.sdk.api.request']/class[@name='LCAPIRequest']/field[@name='dispatch']" />
    <remove-node path="/api/package[@name='com.lightcurb.sdk.api.request']/class[@name='LCAPIRequest']/field[@name='response']" />
    <remove-node path="/api/package[@name='com.lightcurb.sdk.api.request']/class[@name='LCAPIRequest']/field[@name='responseInt']" />
    <remove-node path="/api/package[@name='com.lightcurb.sdk.api.request']/class[@name='LCAPIRequest']/field[@name='responseList']" />
    <remove-node path="/api/package[@name='com.lightcurb.sdk.api.request']/class[@name='LCAPIRequest']/field[@name='responseObject']" />
    <remove-node path="/api/package[@name='com.lightcurb.sdk.api.request']/class[@name='LCAPIRequest']/field[@name='responseString']" />

</metadata>

as you can see my <add-node path="/api/package[@name='com.radiusnetworks.ibeacon']/interface[@name='MonitorNotifier']"></add-node> isn't found. What am i doing wrong here? And more importantly how can i fix it?

P.S. The remove-nodes i implemented because of duplicate fields.

Thanks in advance!

Sincerely Niels


WinRT ProgressBar over ProgressRing

$
0
0

Just a quick question.
Does anyone know why XForms would choose to use an indeterminate progressbar over a progressring in WinRT based platforms?
It seems like it adds boilerplate as you have to take into account width/height across each platform rather than just setting it once.

ie:
Device.OnPlatform(
Uwp -> Make wider but shorter,
Android -> Generally use a square container,
iOS -> This doesnt even work properly and completely ignores height/width request properties set
)

I know its easily fixed through just ripping their source and modifying to your hearts content as a custom renderer, but just curious as to why this choice was made!

~Ry

Clearing Android activities stack

$
0
0

Hi,
I have home screen in my application, from which user shall navigate to different module by tapping module icons on home screen. Each module has set of activities( drill down screens). Each screen shall have home button for navigating to home screen directly at any point of time.

The expected behavior on tap home button is activities stack has to be cleared so that on back press, previous activity should not be displayed.
So I used the below code

          //home button click navigate to home screen
    _btnHome.Click += (sender, e) => {
            Intent intent = new Intent (activity, typeof(HomeActivity));
            intent.AddCategory (Intent.CategoryHome);
            intent.SetFlags (ActivityFlags.ClearTop | ActivityFlags.NewTask);
            activity.StartActivity (intent);
    };

But on back press, still I am able to see previous screen, which means the activity stack is not cleared.

Kindly need your help for resolving this issue.

Thanks in advance,

How to change the Accessory BackgroundColor for my custom table cell?

$
0
0

I'm a long-time C# guy, but I'm new to Xamarin (and mobile development, in general).

I have set the my TableView as transparent in my view controller:

myTableView.BackgroundView = null;
myTableView.BackgroundColor = UIColor.Clear;

and given my custom cell a semi-transparent view to allow a background image to show through:

ContentView.BackgroundColor = UIColor.FromWhiteAlpha(1f, 0.1f);

and it all works perfectly, except for the cell.accessories. Depending on the situation, I show a checkmark or a detail button in GetCell, but they render with the clear background of the table instead of the rest of the cell. I'm pretty sure I need to do something with AccessoryView in my custom cell class, but I haven't been able to figure it out or find a solution with my searches.

Any help would be appreciated, Thanks.

How to close view on selection of CollectionView Item?

$
0
0

Hi All,

I got stuck in this , i am successfully showing collection view with some images now i have to close this view from main view on clicking of collection view item, this is my code

NSView :-

 public override void AwakeFromNib ()
 {
      base.AwakeFromNib ();
      PeopleArray.AddObserver ("selectionIndexes", NSKeyValueObservingOptions.New, (sender) => {
            RaisePersonSelected((nint)PeopleArray.SelectionIndex);
      });
 }

ViewController :-

View.PersonSelected += (index) => {
try
   {
        SelectedPerson = _people.GetItem<PersonModel>((nuint)index);
        this.View.RemoveFromSuperview();
   }
  catch {
       SelectedPerson = null;
            }
  };

after clicking on collection view item its going to await mode :( , Can anyone help me to go right direction ...

About xamarin forms application

$
0
0

Hi all,

a quick question:

may a xamarin forms application run on Windows 10 PC too ?

Thanks in advance.

Viewing all 204402 articles
Browse latest View live


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