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

Is there a way to use GestureRecognizers in ViewCells while letting ListView handle the gestures?

$
0
0

When you select an item in a ListView, the ListView has handles the gestures and, in turn, the SelectedItem property changes.

When you add a gesture recognizer to a View (say, a Label) in a ViewCell, it then consumes the gesture and lets you handle it, however if you select an item with this gesture recognizer, the ListView essentially not know it was selected, and it's SelectedItem property will not change.

Is there a way to allow a gesture to be handled by both your gesture recognizer and the listview? I have tried making my gesture recognizer invoke a two-way binding to SelectedItem inside the pages ViewModel to manually emulate it, however that does not seem to be enough to mimic the original behaviour (it still thinks the last item selected was not the one with the gesture recognizer, so if you tap back on the previous one afterwards it won't handle it).

Any ideas?

Thank you for your time


how to fetch contacts from phone to list view in xamarin forms for both android and ios?

$
0
0

how to fetch contacts from phone to list view in xamarin forms for both android and ios?

how to fetch contacts list from phone to listview in xamarin forms for both android and ios?

$
0
0

how to fetch contacts list from phone to listview in xamarin forms for both android and ios?

Crash with Xamarin.Auth 1.6.0.2 opening the default AccountStore

$
0
0

Hello,

Looks like since I upgraded Xamarin.Auth my application is now crashing at startup with a Java.IO.IOException "KeyStore integrity check failed.".

I found that the method signature to fetch an existing AccountStore changed a bit and one is now supposed to provide a custom password:

var password = "1234567890ABCDEF...";
var account = AccountStore.Create(LocalContext, password).FindAccountsForService("My Application").FirstOrDefault();

before it was:

var account = AccountStore.Create(LocalContext).FindAccountsForService("My Application").FirstOrDefault();

However, I get the aforementioned exception and it crashes my app at startup (since I try to read some settings).

I found this code to migrate old content to a new AccountStore: https://github.com/xamarin/Xamarin.Auth/pull/56/commits/f0aad93c37cb5bbcdeb56e59ecf7f9cb9ffbf48c

However it does not help.

My questions:

  1. How can I just throw every associated AccountStore without getting the exception? I'm fine not "migrating" but cannot open the old AccountStore even if I provide the password supposed to be the old default one as in the pull request.
  2. Is there anything else I should know?
  3. That's cool not to have a default hardcoded password but if my app now hardcode its own password, I'm really not sure this is "better" since this may be most probably easily bet read by opening the binary. So what would be the best way to choose some password to use for storing secret settings for my app?

Thanks.

Build has broken by adding a Nuget package which uses Microsoft.NETCore.Portable.Compatibility

$
0
0

Hi, I'm a new developer for Xamarin.Forms.

Last night, I've created new Xamarin.Forms app with Android only.
It was builded successfully on first time, but after I added 'Combinatorics' package, the build is broken.

Belows are logged errors.
CSC : error CS1703: Multiple assemblies with equivalent identity have been imported: 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v1.0\mscorlib.dll' and 'C:\Users\User\.nuget\packages\microsoft.netcore.portable.compatibility\1.0.1\ref\netstandard1.0\mscorlib.dll'. Remove one of the duplicate references.

And related on this error, there are many errors like
Resources/Resource.designer.cs(12,36): error CS0731: The type forwarder for type 'System.Attribute' in assembly 'System.Runtime' causes a cycle
and
Resources/Resource.designer.cs(409,17): error CS0518: Predefined type 'System.Int32' is not defined or imported

'Combinatorics' package depends on 'Microsoft.NETCore.Portable.Compatibility' and I can't remove this dependency.

Is there any solution for this?
Attached file is repro of this issue and here is my environment.

Microsoft Visual Studio Professional 2017
Version 15.5.7
VisualStudio.15.Release/15.5.7+27130.2036
Microsoft .NET Framework
Version 4.7.02556

Visual C# 2017 00370-20007-76118-AA391

Merq 1.1.17-rc (cba4571)

Mono Debugging for Visual Studio 4.8.4-pre (3fe64e3)

NuGet Package Manager 4.5.0

VisualStudio.Mac 1.0
Mac Extension for Visual Studio

Xamarin 4.8.0.760 (fc93f3f5b)
Xamarin.iOS と Xamarin.Android の開発を有効にする Visual Studio 拡張機能

Xamarin Designer 4.8.188 (c5813fa34)
Visual Studio extension to enable Xamarin Designer tools in Visual Studio.

Xamarin.Android SDK 8.1.5.0 (HEAD/75f8c6838)
Xamarin.Android Reference Assemblies and MSBuild support.

Xamarin.iOS and Xamarin.Mac SDK 11.6.1.4 (db807ec)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.

ユニバーサル Windows アプリ用 Visual Studio Tools 15.0.27130.2036
ユニバーサル Windows アプリ用 Visual Studio Tools を使用すると、電話、タブレット、PC など、Windows 10 を実行している各デバイスで使用できるユニバーサル アプリの単一ビルドを利用できます。これには Microsoft Windows 10 ソフトウェア開発キットが含まれています。

Please help!

xamarin shell package did not load correctly

$
0
0

hi .........

after Visual studio 15.6.6 update i got this error when i load the project ( xamarin shell package did not load correctly )

any help please :(

How to hide/show button on content page from app class- Xamarin Forms?

$
0
0

I want to hide/show button on content page by timer from my app class. I try create global resources and change it by timer, but application breaks down(missing navigation and etc) . Help please...

Xamarin TapGestureRecognizer - VB Example

$
0
0

I'm trying to add an Xamarin.Forms TapGestureRecognizer onto a stacklayout in code behind in VB.

I've Converted this code from an Xamarin example here:

xxxx://github.com/xamarin/xamarin-forms-samples/blob/master/Xuzzle/Xuzzle/Xuzzle/XuzzlePage.cs

`TapGestureRecognizer tapGestureRecognizer = new TapGestureRecognizer {
Command = new Command (OnSquareTapped),
CommandParameter = square
};
square.GestureRecognizers.Add (tapGestureRecognizer);

async void OnSquareTapped (object parameter)
{
//do something
}`

When I convert to VB, I get the following code.

`Private tapGestureRecognizer As TapGestureRecognizer = New
TapGestureRecognizer With {.Command = New Command(OnSquareTapped),
.CommandParameter = square}

Private Async Sub OnSquareTapped(ByVal parameter As Object)
//do something
End Sub`

'Argument not specified for parameter'

Then when I add a parameter I get

'Expression does not produce a value'

If I change OnSquareTapped to a Function I get

'the Overload resolution failed...'

I can't find a working example anywhere in VB and a lot of the C# examples either use depreciated methods or Lamda, which I'm not familiar with.

Can anyone provide a working VB example - with an explanation as to where I'm going wrong?


Xamarin MediaPlugin Video Resolution

$
0
0

Is it possible to change the video resolution using this plugin? By default is recording in FHD, however I wanted to be just VGA (800*640). I've tried to set Quality = Plugin.Media.Abstractions.VideoQuality.Low, however the size of the video is quite the same.

PanGesture on item in ListView getting canceled, but only on Android

$
0
0

Hello!

I am making a swipe-to-delete function in my Xamarin Forms-project.
My current code works perfectly on iOS and UWP, but on Android the swipe gets canceled at random times.
Sometimes when i swipe it works for several seconds before getting canceled, and sometimes it gets canceled directly.

So what do i mean by "canceled"? It stops listening on the touch events, it freezes (look at image below) the element in place, and i have to lift my finger from the screen and press again to start firing touch events again. Moving around the finger and doing swipes after a freeze gives no events at all.

I am at a loss here, and i cant seem to find what is causing my cancelation of the swipe.

UPDATE:
It seems that the swipe works perfectly on Android while i only swipe left-to-right or right-to-left.
But if i move even 1 pixel vertical (up-to-down och down-to-up) it cancels the swipe completely and instead focusing on scrolling the listview.

-- IMAGE --

What is seen here is the first element in the standard position and the two other elements freezed while doing swipes on them

-- CODE --

Xaml with the ListView:
https://pastebin.com/8u8LPb2E

Xaml for "uiElements:CartViewCell" ( my ViewCell)
https://pastebin.com/zhq2YDWL

Code behind for ViewCell:
https://pastebin.com/XrUBLsBe

Cheers,
Tobias

How to show .PKPASS in app using Xamarin.forms

$
0
0

Generated PKPASS in .NET backend app. Now Xamarin.forms mobile app downloaded .PKPASS and stored locally. How can we show same .PKPASS in app with ADD to wallet option?

Problem with Xml Deserialization using Xamarin XmlSerializer class

$
0
0

Hi,

I have got a strang problem (from my current point of view).
I have a xsd file that defines the schema of some http-communication. This xsd-file is not a simple one. If you like, you can download it here https://www.vdv.de/trias-xsd-v1.2.zipx?forced=true .
I used the Xsd2Code+ Extension for Visual Studio to create classes based on this xsd file (default settings, but GenerateOrderXmlAttributes = True, GenerateXmlAttributes = True and CollectionObjectType = Array).

I created and used the services I need based on .Net Core that way without any issues. The generated classes are working fine. After that I want to implement this classes also in my Xamarin project, but it didn't work. After some hours I am sure, that there is something wrong (or different) in Xamarin than in .Net and .Net Core.
I created a minimal test solution with a Xamarin and a .Net Core app. The .Net Core app is running fine again - like in my previous .Net Core project. The Xamarin app had the same problem - so I am able to reproduce the problem.

For both projects I am using the same code with a minimal XML-Code example:

var xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> <Trias xmlns=\"http://www.vdv.de/trias\" version=\"1.2\"> <ServiceDelivery> <ResponseTimestamp xmlns=\"http://www.siri.org.uk/siri\">2018-04-22T15:40:20Z</ResponseTimestamp> <ProducerRef xmlns=\"http://www.siri.org.uk/siri\">EFAController10.2.10.2-EFA-STATIC02</ProducerRef> <Status xmlns=\"http://www.siri.org.uk/siri\">true</Status> <MoreData>false</MoreData> <Language>de</Language> <DeliveryPayload> <LocationInformationResponse> <LocationResult> <Location> <StopPoint> <StopPointRef>de:08115:5947</StopPointRef> <StopPointName> <Text>Hauptstraße</Text> <Language>de</Language> </StopPointName> <LocalityRef>8115051:6</LocalityRef> <WheelchairAccessible>false</WheelchairAccessible> <Lighting>false</Lighting> <Covered>false</Covered> </StopPoint> <LocationName> <Text>Weil im Schönbuch</Text> <Language>de</Language> </LocationName> <GeoPosition> <Longitude>9.05147</Longitude> <Latitude>48.62194</Latitude> </GeoPosition> </Location> <Complete>true</Complete> <Probability>0.958000004</Probability> <Mode> <PtMode>bus</PtMode> <BusSubmode>localBus</BusSubmode> </Mode> <Mode> <PtMode>bus</PtMode> <BusSubmode>expressBus</BusSubmode> </Mode> <Mode> <PtMode>bus</PtMode> <BusSubmode>demandAndResponseBus</BusSubmode> </Mode> </LocationResult> </LocationInformationResponse> </DeliveryPayload> </ServiceDelivery> </Trias>";

await streamWriter.WriteAsync(xml);
streamWriter.Flush();
responseStream.Position = 0;

XmlSerializer x = new XmlSerializer(typeof(Trias));    
object res = x.Deserialize(responseStream);

if (((ServiceDeliveryStructure)((Trias)res).Item).DeliveryPayload != null)
    Debug.WriteLine("Deserialization successful");
else
    Debug.WriteLine("Deserialization failed");

The result is, as described, different. The res-objects contain a property called Item that contains a property called DeliveryPayload. This property contains the data I need, but that are not present (null) at Xamarin.
I attached the solution I created for testing in case you want to reproduce the issue by yourself.

Is there a bug in Xamarin or is there something wrong the way I am using it?

Why the application is closed after trying to enter a data in an entry box?

$
0
0

The application closes without showing any error, this happens when I try to enter some data an Entry Box, I'm using SQLite and I have ViewModels binding with the Views, using the INotifyPropertyChanged interface in the model.
I do not know why that happens, as long as you do not try to enter some value the application does not close.

My email is ymedero90@gmail.com

Why the application is closed after trying to enter a data in an entry box?

$
0
0

Why the application is closed after trying to enter a data in an entry box?

How to upload image on server

$
0
0

Hi All,

I am trying to uploading image from Xamarin.forms.
I am getting 500 internal server error. While i am using "Postman" for uploading image , It was working fine.
Please have a look on my code and Postman screen shot.
Please help me , I am struggling from last 3 days.
//Code

using (var memoryStream = file.GetStream())

           {
              using (var streamContent = new System.Net.Http.StreamContent(memoryStream))
              {
                  using (var byteArrayContent = new ByteArrayContent(await streamContent.ReadAsByteArrayAsync()))
                   {
                       using (var formDataContent = new MultipartFormDataContent())
                       {
                           var client = new HttpClient();
                           string authKey = "0000000-8061-4af4-ac34-ac9df0482308";
                           client.DefaultRequestHeaders.Add("Authorization", authKey);
                            string url = "https://api.xxx.com/UserProfilePhoto?0000-092-7282-1939";
                            formDataContent.Add(byteArrayContent, "ImageData", fileName);
                            foreach (var content in formDataContent)
                            {
                               content.Headers.ContentType = new MediaTypeHeaderValue("image/jpg");
                                break;
                            }
                                                         formDataContent.Add(new System.Net.Http.StringContent("Profile"), "PhotoType");
                            formDataContent.Add(new System.Net.Http.StringContent(fileType), "FileType");
                            var response = await client.PostAsync(url, formDataContent);
                        }
                    }
                }
            }

Play local file with MedaiManager

$
0
0

Hi, I'm trying to play a video stored locally using MedaiManager. Do I need to put it in the PCL project or in the iOS > Resources folder? And is this set to Content or Embedded in the properties of the file?

I took a look through the samples but couldn't see anything specific to playing a local video file:

https://forums.xamarin.com/discussion/94847/play-video-pcl-project

Any suggestions? TIA

IMarkupExtension with custom Services in the IServiceProvider

$
0
0

I'm building a Markup extension that needs access to a Service. Obviously I don't want to create a static somewhere to access it, and I equally can't do constructor injection, so I'm wondering if there's any magical way to add my own Service to the collection of services that get passed into the ProvideValue(IServiceProvider serviceProvider) method?

how to extract numbers from a string and add them

$
0
0

I am working on an app that will have to read the variable sms and then add the numbers that I found in it and I have no idea how to do it. IT IS URGENT this is the code

namespace Mensajeria {

public class datos
{
public string num { get; set; }
public string sms { get; set; }

}
} public class men { public List mens { get; set; } public men() { mens = new List(); Load();

}
public void Load()
{

mens.Add(new datos
{
    num = "232843874",
    sms = "aldkajsldkaj 2535335 ñadalksdñka",

}
   );

mens.Add(new datos
{
    num = "3123122",
    sms = "skjdlaskdj 78778 laslajsldj"
});

}

}

XAML Global style - How to access a static class for use color properties?

$
0
0

Hello,

My application will be used by many enterprises and i have a theme color by enterprise.
A theme is storage in a static class on string properties (hexa values).

I want bind the selected enterprise with the App XAML and use it on global style.

Can i do this? How?

Best regards.

Circle button in Xamarin.Forms. Super easy way

$
0
0

Guys, there is super easy way to create Circle/Round buttons in XF.
What you need to do is to use BorderRadius, WidthRequest and HeightRequest (you must use all these properties)
Make in mind simple formula:
WidthRequest = BorderRadius * 2
HeightRequest = BorderRadius * 2

or another way:
BorderRadius = WidthRequest / 2
BorderRadius = HeightRequest / 2

So finally, if your WidthRequest and HeightRequest both are equals 40, then your BorderRadius will be 20.
See the attached screens for this simple and nice hack :)

simple text:

font awesome:

Viewing all 89864 articles
Browse latest View live


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