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

Photo + Json In xamarin post webservice

$
0
0

Hi,

I want to add a json and photo(MultipartFormDataContent) in xamarin post webservice.

I know how to add json alone, but for adding image i didn't get any code.

I used many open sources, but got no luck.

Can someone please share source code which is working well?

Thanks in advance.


Visual studio Installation stuck at a point.

$
0
0

Hi everybody,

I am new with xamarin.
When i install xamarin and uwp into visual studio, installation stuck at a point. Picture attaching below:

Almost 3 hours are spent for downloading. But not moving the downloading status.
What is Applying android image_x86_API25?
Why this happening? I don't know. Anybody please help me.

Error java.lang.IllegalArgumentException: already added

$
0
0

Hi guys
I am new with xamarin

Getting an error like this :
Severity Code Description Project File Line Suppression State
Error java.lang.IllegalArgumentException: already added : Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat; SmartTweet.Android

I update all the nuget packages, but the error still occur.

Anybody please suggest a solution

Thanks in advance... :)

Unable to add theme

Error: Build failed. See the build log for details. (iOS)

$
0
0

Hi,
I am new in Xamarin.
I have install the Visual studio for Mac.
I just add a new Blank Xamarin Forms Project.
When i try to run the app it's throwing Build error.
"Error: Build failed. See the build log for details. (iOS)"

Please Help to resolve this error.

Thanks

How to add a background image to an Entry?

$
0
0

Hi, my designer created a background image to style the inputs it looks like the image attached.
How could I accomplish that in Xamarin.Forms?
The easy part I'm guessing is removing the border, but I also need to position it on top of that (I'd assume using RelativeLayout?) and the hardest (in my point of view) setting its proper size.
I'm using XAML, but if you know in C# I can extrapolate that, no problem.
Any ideas?

EDIT:

The second image is what I've managed to do so far with this code:

<RelativeLayout>
  <Image Source="input_selected.png"></Image>
  <StackLayout Orientation="Horizontal" HorizontalOptions="CenterAndExpand">
    <Image Source="ico_password.png" Scale="0.7"></Image>
    <Entry x:Name="PasswordT" Placeholder="Senha" IsPassword="True" HorizontalOptions="CenterAndExpand" Text="offspring"></Entry>
  </StackLayout>
</RelativeLayout>

Thanks!

How to Use Navigation Push ASync in Master Detail Page Menu

$
0
0

I want to make my xamarin forms app when the menu item is clicked instead change the master detail page it go to another page and create navigation bar with back button in the top. but i got confused in how to change the on menu item selected, here is my onmenuitemSelected

private void OnMenuItemSelected(object sender, SelectedItemChangedEventArgs e)
{

        var item = (DrawerItem)e.SelectedItem;
        Type page = item.TargetType;

        //Navigation.PushAsync((Page)Activator.CreateInstance(page));


        Detail = new NavigationPage((Page)Activator.CreateInstance(page));
       IsPresented = false;
    }

as you can see in the comment tag i already try to do Navigation.Push async but when im click the menu item its do nothing, so what code should i write to do that.

Xamarin.Forms.Xaml.XamlParseException: Position 9:10. Type infra:InstanceLocator not found in xmlns

$
0
0


I am compiling my App project in Visual Studio and it throws me the error: Xamarin.Forms.Xaml.XamlParseException: Position 9:10. Type infra: InstanceLocator not found in xmlns clr-namespace: SITApp3.Infrastructure; assembly = SITApp3
Does anyone know how I can solve it?
Thank your contributions


How to refresh Fragment

$
0
0

Hi All,

I have an issue in rendering/refreshing fragment.I have used Detach and Attach method for refreshing fragment.But not refreshing/displaying the fragment.Please anyone suggest me.

I have done the following steps.
**
My code snippet is below**

var transaction= FragmentManager.BeginTransaction();
if(FragmentManager.FindFragmentByTag("FragmentName")==null)
{
MyFragment fragment= new MyFragment();
transaction.Add(Resource.Id.HomeFrameLayout, fragment);
transaction.Commit();
break;
}
else
{
transaction.Detach(FragmentManager.FindFragmentByTag("FragmentName"));
transaction.Attach(FragmentManager.FindFragmentByTag("FragmentName"));
transaction.Commit();
}

Thanks in Advance
SabariSankar

The "ResolveLibraryProjectImports" task failed unexpectedly.

$
0
0

I just installed VS 2017.
Got this warning after creating a cross platform project.

Severity Code Description Project File Line Suppression State
Warning The "ResolveLibraryProjectImports" task failed unexpectedly.
System.IO.FileNotFoundException: Could not load assembly 'App1, Version=0.0.0.0, Culture=neutral, PublicKeyToken='. Perhaps it doesn't exist in the Mono for Android profile?
File name: 'App1.dll'
at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(AssemblyNameReference reference, ReaderParameters parameters)
at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(String fullName, ReaderParameters parameters)
at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(String fullName)
at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.GetAssembly(String fileName)
at Xamarin.Android.Tasks.ResolveLibraryProjectImports.Extract(DirectoryAssemblyResolver res, ICollection1 jars, ICollection1 resolvedResourceDirectories, ICollection1 resolvedAssetDirectories, ICollection1 resolvedEnvironments)
at Xamarin.Android.Tasks.ResolveLibraryProjectImports.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext() App1.Android

how to use Sqlite in Shared project

$
0
0

hey
as i mentioned in the title
how to use Sqlite in Shared project
all what i have found is tutorials for PCL projects only
please help

MainPage = new NavigationPage(aPage); no longer works?

$
0
0

I previously use
MainPage = new NavigationPage(main);
in App.cs and those works fine. but since Visual studio community 2015 and 2017 updated to latest, this line code get exception and not able catch it in my own try-catch

How to use Constraints Layout?

$
0
0

Hi,

Did anyone know how to apply the constraints layout?
Like in android studio, they have a feature where user can drag and resize according to the position they wanted by using constraints layout.

I was wandering did Visual Studio to have such function?

Please kindly advice me.
Thanks :smile:

How to get file content of file which is choosen when calling Intent.CreateChooser

$
0
0

I have created an intent to open dialog box for user to pick file from android file system
Intent intent = new Intent(Intent.ActionGetContent);
intent.SetType("/");
intent.AddCategory(Intent.CategoryOpenable);
StartActivityForResult(Intent.CreateChooser(intent, "Select a file"),0);
the dialog box opens and I choose a file , but then nothing happens. I read that I have to put some logic in
public void onActivityResult(int requestCode, int resultCode, Intent data)
{}
I created that method in MainActivity where my intent instantiation is. But after I've choosen the file from filebrowser than method don't get called

Difference for Entry IsPassword and Keyboard=Numeric (Android)

$
0
0

Hello

my login page has two entries.
Both of them are Keyboard="Numeric"

The second one has additionally IsPassword="True"

On my second entry the keyboard only shows numbers.
But on the first one without IsPassword, it also shows "- + , * /" etc.

Im Testing on a tablet. Maybe the layout on a phone is different.


How do i POST/ PUT a large image to REST service

$
0
0

I am trying to post a 5MB size image in byte array format together with other data and send it to REST , on the REST service side it end up with "Empty" Object. However if i try with small images like few hundreds KB, REST service will successfully receive a complete object which contain the byte array as well. Is there any solution on this issue? No exception was caught during the process. Note: Im sending one image at a time.

Here is my model class.

public class PunchAttachmentModel
{
    public Guid attachmentuniqueid { get; set; }
    public String attachmentfilename { get; set; }
    public Guid filetypeuniqueid { get; set; }
    public DateTime attachmentdate { get; set; }
    public String attachmentremark { get; set; }
    public byte[] attachmentbinary { get; set; }
    public Guid punchitemuniqueid { get; set; }
}

My Post Async:
public async Task PostAsync(T t, string weburl)
{
var uri = new Uri(string.Format(weburl, string.Empty));
try
{
var httpclient = new HttpClient();
var json = JsonConvert.SerializeObject(t);
HttpContent httpcontent = new StringContent(json);
httpcontent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");
var result = await httpclient.PostAsync(uri, httpcontent);
}
catch(Exception e){

}

}

**RestService Post **

    [ResponseType(typeof(PunchAttachmentModel))]
    public IHttpActionResult PostPunchAttachment(PunchAttachmentModel attachment)
    {..............................}

Editor Looses focus and moves up when its tapped for edit in xamarin iOS

$
0
0

I am using a editor control and on tapping of it i want edit the text but it moves up and not able to see the text in Xamarin iOS for android its working fine

Can't Add Apple Developer Account to Visual Studio

$
0
0

I'm trying to add a developer account to my visual studio for mac, when I enter my apple Id and password I'm getting another auth box .

Visual Studio wants to access key "deliver.[APPLEID]" in your keychain.
To allow this, enter the "login" keychain password.

I tried using my Apple ID password as well as my computer login password which neither work. I'm not entirely sure what deliver.[APPLEID] is?

App crashes on certain events

$
0
0

Hi guys,

I've written an app with a multi-page form in Xamarin Forums. Users complain about getting errors I can hardly reproduce. There's no way to test this while debugging.

HockeyApp gives me this error when they switch x times back and forth between the pages and then click on a button (and only a button), not a dropdown or other input fields. They render properly and I'm using the last version of Xamarin Forms.
Right now I'm only using Forms for Android, so I can only test this on Android.

<br /> Xamarin caused by: android.runtime.JavaProxyThrowable: System.ObjectDisposedException: Cannot access a disposed object.<br /> Object name: 'Xamarin.Forms.Platform.Android.Platform+DefaultRenderer'.<br /> Java.Interop.JniPeerMembers.AssertSelf(IJavaPeerable self)<bd30a18775d94dc8b6263aecd1ca9077>:0<br /> Java.Interop.JniPeerMembers.JniInstanceMethods.InvokeVirtualVoidMethod(string encodedMember, IJavaPeerable self, JniArgumentValue* parameters)<bd30a18775d94dc8b6263aecd1ca9077>:0<br /> Android.Views.View.SetBackgroundColor(Color color)<9ab9faae1b4b4f0da28e7c4ac61e2c78>:0<br /> Xamarin.Forms.Platform.Android.VisualElementRenderer<TElement>.UpdateBackgroundColor()<8783e2b68568446a8522c36407e66253>:0<br /> Xamarin.Forms.Platform.Android.VisualElementRenderer<TElement>.OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)<8783e2b68568446a8522c36407e66253>:0<br /> <Module>.invoke_void_object_PropertyChangedEventArgs(object, PropertyChangedEventArgs)(wrapper delegate-invoke)<br /> Xamarin.Forms.BindableObject.OnPropertyChanged(string propertyName)<6e20d7af277949f4a7bb952d64b81cda>:0<br /> Xamarin.Forms.Element.OnPropertyChanged(string propertyName)<6e20d7af277949f4a7bb952d64b81cda>:0<br /> Xamarin.Forms.BindableObject.SetValueActual(BindableProperty property, BindableObject.BindablePropertyContext context, object value, bool currentlyApplying, BindableObject.SetValueFlags attributes, bool silent)<6e20d7af277949f4a7bb952d64b81cda>:0<br /> Xamarin.Forms.BindableObject.SetValueCore(BindableProperty property, object value, BindableObject.SetValueFlags attributes, BindableObject.SetValuePrivateFlags privateAttributes)<6e20d7af277949f4a7bb952d64b81cda>:0<br /> Xamarin.Forms.BindingExpression.ApplyCore(object sourceObject, BindableObject target, BindableProperty property, bool fromTarget)<6e20d7af277949f4a7bb952d64b81cda>:0<br /> Xamarin.Forms.BindingExpression.Apply(bool fromTarget)<6e20d7af277949f4a7bb952d64b81cda>:0<br /> Xamarin.Forms.BindingExpression.BindingExpressionPart.<PropertyChanged>b__47_0()<6e20d7af277949f4a7bb952d64b81cda>:0<br /> Java.Lang.Thread.RunnableImplementor.Run()<9ab9faae1b4b4f0da28e7c4ac61e2c78>:0<br /> Java.Lang.IRunnableInvoker.n_Run(IntPtr jnienv, IntPtr native__this)<9ab9faae1b4b4f0da28e7c4ac61e2c78>:0<br /> at (wrapper dynamic-method) System.Object:94a3beb6-4f7c-4b9d-958e-0e8b8d73194b (intptr,intptr)<br /> mono.java.lang.RunnableImplementor.n_run(Native Method)<br /> mono.java.lang.RunnableImplementor.run()RunnableImplementor.java:30<br /> android.os.Handler.handleCallback()Handler.java:751<br /> android.os.Handler.dispatchMessage()Handler.java:95<br /> android.os.Looper.loop()Looper.java:154<br /> android.app.ActivityThread.main()ActivityThread.java:6120<br /> java.lang.reflect.Method.invoke(Native Method)<br /> com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run()ZygoteInit.java:865<br /> com.android.internal.os.ZygoteInit.main()ZygoteInit.java:755<br />

Because of a memoryleak in Forms, I had to change it to images with FFImageLoading.
Unfortunately, I cannot post much code, but this is the grid row that keeps crashing:
<br /> <?xml version="1.0" encoding="utf-8" ?><br /> <Grid xmlns="n.com/schemas/2014/forms" xmlns:x="ft.com/winfx/2009/xaml" xmlns:forms="clr-namespace:FFImageLoading.Forms;assembly=FFImageLoading.Forms" xmlns:extensions="clr-***.Extensions;assembly=***" x:Class="***.Views.Editors.BooleanEditor" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Padding="5,0" x:Name="Grid" IsVisible="{Binding Visible}" HeightRequest="80"><br /> &lt;Grid.RowDefinitions><br /> <RowDefinition Height="80"/><br /> &lt;/Grid.RowDefinitions></p> <p>&lt;Grid.ColumnDefinitions><br /> <ColumnDefinition Width=".2*"/><br /> <ColumnDefinition Width="1*"/><br /> <ColumnDefinition Width="3*"/><br /> <ColumnDefinition Width="1*"/><br /> <ColumnDefinition Width="6*"/><br /> <ColumnDefinition Width=".5*"/><br /> <ColumnDefinition Width="1*"/><br /> <ColumnDefinition Width=".5*"/><br /> <ColumnDefinition Width="1*"/><br /> <ColumnDefinition Width=".5*"/><br /> &lt;/Grid.ColumnDefinitions></p> <p>&lt;Grid.Children><br /> <forms:CachedImage Grid.Row="0" Grid.Column="0" WidthRequest="24" HeightRequest="24" DownsampleHeight="24" DownsampleWidth="24" Source="{extensions:ImageResource ***.Images.info.png}" HorizontalOptions="Start" VerticalOptions="Center" IsVisible="{Binding HasMemo}" CacheType="All" Margin="15,0,0,0"><br /> &lt;forms:CachedImage.GestureRecognizers><br /> <TapGestureRecognizer Command="{Binding BindingContext.ItemHelpCommand, Source={x:Reference Grid}}"/><br /> &lt;/forms:CachedImage.GestureRecognizers><br /> </forms:CachedImage></p> <pre><code><ContentView Grid.RowSpan="1" Grid.Row="0" Grid.Column="2" VerticalOptions="FillAndExpand"> <StackLayout Spacing="0" VerticalOptions="End" Margin="0,0,0,25"> <StackLayout Spacing="0"> <Label HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" HorizontalTextAlignment="Start" VerticalTextAlignment="Center" Text="{Binding Name}" FontSize="14"/> </StackLayout> <Label IsVisible="{Binding Required, Converter={StaticResource InvertBoolean}}" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" HorizontalTextAlignment="Start" VerticalTextAlignment="End" Text="{extensions:Translate DynamicFormOptional}" FontSize="10"/> </StackLayout> </ContentView> <ContentView BackgroundColor="{Binding BgColor}" Grid.Row="0" Grid.Column="4" Margin="0,0,0,12"> <Grid> <Grid.RowDefinitions> <RowDefinition Height="20"/> <RowDefinition Height="*"/> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/> </Grid.ColumnDefinitions> <Grid.Children> <Label Grid.Row="0" Grid.Column="0" HorizontalOptions="Start" VerticalOptions="FillAndExpand" HorizontalTextAlignment="Start" VerticalTextAlignment="Center" Text="{Binding PreviousValue, Converter={StaticResource TextTranslation}}" IsVisible="{Binding BindingContext.ValueHasChanged, Source={x:Reference Grid}}" /> <Label Grid.Row="0" Grid.Column="0" HorizontalOptions="Start" VerticalOptions="FillAndExpand" HorizontalTextAlignment="Start" VerticalTextAlignment="Center" IsVisible="{Binding BindingContext.ValueHasChanged, Source={x:Reference Grid}, Converter={StaticResource InvertBoolean}}" /> <forms:CachedImage VerticalOptions="Center" Grid.Row="1" Grid.Column="0" DownsampleToViewSize="True" Source="{extensions:ImageResource ***.Images.buttonNoOff.png}" IsVisible="{Binding Value, Converter={StaticResource NullableBoolean}, ConverterParameter=True}" CacheType="All"> <forms:CachedImage.GestureRecognizers> <TapGestureRecognizer Command="{Binding BindingContext.BooleanNoCommand, Source={x:Reference Grid}}"/> </forms:CachedImage.GestureRecognizers> </forms:CachedImage> <forms:CachedImage VerticalOptions="Center" Grid.Row="1" Grid.Column="0" DownsampleToViewSize="True" Source="{extensions:ImageResource ***.Images.buttonNoOn.png}" IsVisible="{Binding Value, Converter={StaticResource InvertNullableBoolean}}" CacheType="All"> <forms:CachedImage.GestureRecognizers> <TapGestureRecognizer Command="{Binding BindingContext.BooleanNoCommand, Source={x:Reference Grid}}"/> </forms:CachedImage.GestureRecognizers> </forms:CachedImage> <forms:CachedImage VerticalOptions="Center" Grid.Row="1" Grid.Column="1" WidthRequest="147" HeightRequest="100" DownsampleHeight="40" DownsampleWidth="147" DownsampleToViewSize="False" Source="{extensions:ImageResource ***.Images.buttonYesOff.png}" IsVisible="{Binding Value, Converter={StaticResource InvertNullableBoolean}, ConverterParameter=True}" CacheType="All"> <forms:CachedImage.GestureRecognizers> <TapGestureRecognizer Command="{Binding BindingContext.BooleanYesCommand, Source={x:Reference Grid}}"/> </forms:CachedImage.GestureRecognizers> </forms:CachedImage> <forms:CachedImage VerticalOptions="Center" Grid.Row="1" Grid.Column="1" WidthRequest="147" HeightRequest="100" DownsampleHeight="40" DownsampleWidth="147" DownsampleToViewSize="False" Source="{extensions:ImageResource ***.Images.buttonYesOn.png}" IsVisible="{Binding Value, Converter={StaticResource NullableBoolean}}" CacheType="All"> <forms:CachedImage.GestureRecognizers> <TapGestureRecognizer Command="{Binding BindingContext.BooleanYesCommand, Source={x:Reference Grid}}"/> </forms:CachedImage.GestureRecognizers> </forms:CachedImage> </Grid.Children> </Grid> </ContentView> <forms:CachedImage Grid.RowSpan="2" Grid.Row="0" Grid.Column="6" WidthRequest="24" HeightRequest="24" DownsampleHeight="24" DownsampleWidth="24" DownsampleToViewSize="False" Source="{Binding HasIssue, Converter={StaticResource HasIssueBoolConverter}}" IsVisible="{Binding HasIssueColumn}" CacheType="All"> <forms:CachedImage.GestureRecognizers> <TapGestureRecognizer Command="{Binding BindingContext.HasIssueCommand, Source={x:Reference Grid}}"/> </forms:CachedImage.GestureRecognizers> </forms:CachedImage> <forms:CachedImage Grid.RowSpan="2" Grid.Row="0" Grid.Column="8" WidthRequest="24" HeightRequest="24" DownsampleHeight="24" DownsampleWidth="24" DownsampleToViewSize="False" Source="{Binding CameraIcon, Converter={StaticResource CameraIconConverter}}" IsVisible="{Binding PictureRequired}" CacheType="All"> <forms:CachedImage.GestureRecognizers> <TapGestureRecognizer Command="{Binding BindingContext.Photo, Source={x:Reference Grid}}"/> </forms:CachedImage.GestureRecognizers> </forms:CachedImage>

</Grid.Children>


<br /> public partial class BooleanEditor : Grid, IEditor<br /> {<br /> public BooleanEditor()<br /> {<br /> InitializeComponent();<br /> }</p> <pre><code> public EditorTypes EditorType => EditorTypes.Boolean; }

I have removed the
<br /> BackgroundColor="{Binding BgColor}"<br />
for testing, but that did not change anything.

Please please help me, I'm getting desperate.

Random number, but not showing the same number twice?

$
0
0

Hello everyone! I am making a game with Xamarin Android.
It has 4 rounds, and I want to show 4 pictures at random, but the problem is that it can show pictures twice, or even more often.

I thought this code would fix it, but sadly it didn't.

if (ActivityGame.playing == false)
{
List alreadyGuessed = new List();

                                    Random randomSound = new Random();
                                    int theSound = randomSound.Next(1, 5);
                                    while (alreadyGuessed.Contains(theSound))
                                        theSound = randomSound.Next(1, 5);
                                    alreadyGuessed.Add(theSound);

                                     return theSound;
                                }

Anyone got any suggestions on how I make sure that it only shows a number once?

Viewing all 204402 articles
Browse latest View live


Latest Images

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