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

How to correctly use event handlers for Focused/Completed/TextChanged events for an entry

$
0
0

Struggling to unsubscribe correctly from events fired for the same entry control. I have seen a similar answer from @JohnHardmanJohnHardman here: https://forums.xamarin.com/discussion/139977/how-to-programmatically-insert-some-text-in-entry-in-any-cursor-position however my requirements are slightly different - I have to use an entry's Focused/Completed for different things, and it seems after tapping these entries (roughly 3-4 times) the events are no longer working correctly and get confused (fire multiple times or not all) It's probably a confusing between the entry getting unfocused on hitting enter. I'm therefore assuming it's a memory leak because the events are not unsubscribed from correctly. Unfortunately, because of the dynamic nature of the entries, I can't use xaml either.

Code sample below:


Entry currentTextEntry = new Entry { BackgroundColor = Color.Transparent, HeightRequest = 16 };
currentTextEntry.Focused += TextInput_Focused;
currentTextEntry.Completed += onTappedEnterForEntry;

private void TextInput_Focused(object sender, FocusEventArgs e)
{
Entry textInput = (Entry)e.VisualElement;

        try
        {
            FontSize.Text = $"{textInput.FontSize}";
            SelectFontSize.Value = textInput.FontSize;
            var italic = italicSwitch.IsToggled;
            var bold = boldSwitch.IsToggled;
            var color = textColorButton.BackgroundColor;

            textInput.TextColor = color;

//other logic
} catch (Exception ex)
{
Debug.WriteLine(ex);
}

        textInput.Focused -= TextInput_Focused;

}

void onTappedEnterForEntry(object sender, EventArgs e)
    {
        SaveTextNotationToDb();

        var textInput = sender as Entry;

        if (textInput != null) textInput.Completed -= onTappedOutsideEntry;
    }

How can we capture the IP address of the router the smartphone is connected to on WiFI ?

$
0
0

I want to get the Ip address of the device from which my smartphone is connected.
Can any one help me that how I do this ?

Thanks a lot in advance

Android Pie - System.Reflection.TargetInvocationException

$
0
0

Hello everyone,
I got an exception when trying to compile my Xamarin Forms app on Nexus 5X emulator (android Pie),
So the exception appears on this line below

public partial class App : Application { public static ILogger logger = DependencyService.Get<ILogManager>().GetLog();

I'm using DependencyService to get the Logging Functionality from IOS/ANDROID projects... I'm facing this problem only with android 9.0 (Pie) !!
this is the exception:

System.Reflection.TargetInvocationException Message=Exception has been thrown by the target of an invocation.

Any suggestions plz? thnx

How to Share this kind of Object to Facebook in Xamarin forms.

$
0
0

Hi All,

I Want to Share This Kind of Share post on Facebook through Our Apps.Please See blow Sample Image.

How to do in Apps Please give me any suggestion

now i unable to Create this scenario in Xamarin forms

Thanks,

Awaneesh !

How to choose images for each list view item?

$
0
0

public AddDetailsPage ()
{
InitializeComponent ();
BindingContext = new Note();
fileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "sig.png");
if (File.Exists(fileName))
{
TemplateImages.Source = ImageSource.FromFile(fileName);

        }
    }

private async void AddPic_Clicked(object sender, EventArgs e)
{
try
{
if (!CrossMedia.Current.IsCameraAvailable || !CrossMedia.Current.IsTakePhotoSupported)
{
await DisplayAlert("No Camera", ":( No camera available.", "OK");
return;
}
else
{
await CrossMedia.Current.Initialize();

                var mediaoption = new PickMediaOptions()
                {
                    PhotoSize = PhotoSize.Medium
                };

                var Selectedimagefile = await CrossMedia.Current.PickPhotoAsync(mediaoption);

                if (Selectedimagefile == null)
                {
                    await DisplayAlert("errrore", "ok", "ok");
                    return;
                }


                var ImageStream = Selectedimagefile.GetStream();



                using (var fileStream = new FileStream(fileName, FileMode.Create))
                {
                    ImageStream.CopyTo(fileStream);
                }



                var imagesoruce = ImageSource.FromFile(fileName);

                TemplateImages.Source = imagesoruce;




            }
        }
        catch
        {
            await DisplayAlert("Alert", "Something Went Wrong", "Ok");
        }



    }

System.Reflection.TypeExtensions Issue

$
0
0

After updating to Visual Studio 16.2.0 and Xamarin Forms 4.1.0.618606, our Android project starting encountering the following build error while trying to use the TypeExtentions object:

The type 'TypeExtensions' exists in both 'System.Reflection.TypeExtensions, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' and 'mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'

None of our projects directly reference either of these files, so they must be included as dependencies for other assemblies.

The only way the project would build is if the “System.Reflection.TypeExtensions.dll” was removed from the following directory:

C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v1.0\Facades

I assume the compiler must include or search all the files in this directory, so removing it prevents the conflict.

This feels like quite a fundamental issue with the environment and how these files are referenced.

Has anyone else encountered this, or a similar problem?

Custom Renderer Nullable DatePicker with EventToCommandBehaviour on Unfocused not working

$
0
0

Hi,

I've used the following post to implement a nullable DatePicker:

https://xamgirl.com/clearable-datepicker-in-xamarin-forms/

and the following code to create the NullableDatePicker and bind to a command:

var datePicker = new NullableDatePicker()
{
    BindingContext = rfi,
    FontSize = 14,
    HorizontalOptions = LayoutOptions.FillAndExpand,
    TextColor = Color.White,
    BackgroundColor = Color.FromHex("#4c5a63")
};

datePicker.SetBinding(NullableDatePicker.NullableDateProperty, new Binding("Response", BindingMode.TwoWay, new StringToDateConverter(), "dd/MM/yyyy"));

datePicker.Behaviors.Add(new EventToCommandBehavior()
{
    EventName = "Unfocused",
    Command = _editRfisViewModel.EntryUnfocusedCommand,
    CommandParameter = rfi
});

This implementation doesn't seem to bind the behaviour though as the ViewModel command isn't fired on Unfocus. Can anyone offer some assistance to help how to ensure the Unfocused command fires appropriately?

I've tried;

Element?.Unfocus()

in the custom renderer Dialog Done and Clear event handlers to no avail.

void CreateDatePickerDialog(int year, int month, int day)
{
    NullableDatePicker view = Element;

        _dialog = new DatePickerDialog(Context, (o, e) =>
        {
            view.Date = e.Date;
                ((IElementController)view).SetValueFromRenderer(VisualElement.IsFocusedProperty, false);
                Control.ClearFocus();

                _dialog = null;
        }, year, month, day);

        _dialog.SetButton("Done", (sender, e) =>
        {   
            SetDate(_dialog.DatePicker.DateTime);
                this.Element.Format = this.Element._originalFormat;
                this.Element.AssignValue();
        });

        _dialog.SetButton2("Clear", (sender, e) =>
        {
                this.Element.CleanDate();
                Control.Text = this.Element.Format;
        });
}

Any help much appreciated.

How to save multiple images to database

$
0
0
Hi, Xamarin forum the following is my code for selecting multiple images now I dont know how can I grab those images and save it to database I apologize if my code is not properly formatted coz im using mobile phone

XAML














CodeBehind

public partial class PostCreationPage : ContentPage
{
public PostCreationPage()
{
InitializeComponent();

}
private MediaFile _mediaFile;
private string URL { get; set; }
ImageSource ImageSrc;
List _images = new List();
private async void Select_Pic(object sender, EventArgs e)
{
string[] fileTypes = null;

if (Device.RuntimePlatform == Device.Android)
{
fileTypes = new string[] { "image/jpeg" };
}

if (Device.RuntimePlatform == Device.iOS)
{
fileTypes = new string[] { "public.image" };
}
await DependencyService.Get().OpenGallery();
}

private async void Upload_File(object sender, EventArgs e)
{
if (_images == null)
{
await DisplayAlert("Error", "There was an error occured when trying to get your image.", "OK");
return;
}
else
{
UploadImage(_mediaFile.GetStream());
}
}

private async void UploadImage(Stream stream)
{

string userfirstname = App.FirstName;
Pipeline databaseConnect = new Pipeline();

var page = new LoadingPage();
//await stream.ReadAsync(bytes, 0, (int)stream.Length);

try
{

await PopupNavigation.Instance.PushAsync(page);



SqlCommand sqlInsert = new SqlCommand("INSERT INTO t_Post(Post_Content, Photo, Photo_2, Photo_3, Photo_4, Uploader, Date_Uploaded) " +
"VALUES(@PostContent, @Photo, @Photo2, @Photo3, @Photo4, @Uploader, @DateUploaded)", databaseConnect.connectDB());
sqlInsert.Parameters.AddWithValue("@PostContent", postContent.Text);
sqlInsert.Parameters.AddWithValue("@Photo", SqlDbType.Image);
sqlInsert.Parameters.AddWithValue("@Photo2", SqlDbType.Image);
sqlInsert.Parameters.AddWithValue("@Photo3", SqlDbType.Image);
sqlInsert.Parameters.AddWithValue("@Photo4", SqlDbType.Image);
sqlInsert.Parameters.AddWithValue("@Uploader", userfirstname);
sqlInsert.Parameters.AddWithValue("@DateUploaded", DateTime.Now);
int i = sqlInsert.ExecuteNonQuery();
databaseConnect.connectDB().Close();

if (_images == null)
{
await DisplayAlert("Error", "There was an error when trying to get your image.", "OK");
return;
}
else
{
await DisplayAlert("Success", "Uploaded to Database.", "OK");
await PopupNavigation.Instance.PopAsync();
await Navigation.PopAsync();
}
}
catch (Exception ex)
{

}
}

protected override void OnAppearing()
{
base.OnAppearing();

MessagingCenter.Subscribe((App)Xamarin.Forms.Application.Current, "ImagesSelected", (s, images) =>
{


listItems.FlowItemsSource = images;
_images = images;


});
}

protected override void OnDisappearing()
{
base.OnDisappearing();
MessagingCenter.Unsubscribe(this, "ImagesSelected");
}
}
IMediaService.cs

using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace ProjectX.Services
{
public interface IMediaService
{
Task OpenGallery();
void ClearFiles(List filePaths);
}
}

Can no longer start app

$
0
0

I'm writing a XamForms app and as of today I started seeing a strange new behaviour that I believe springs from XCode/iOS.
I get the same behaviour both on simulator and device but different output:

  1. Start app
  2. Launch screen
  3. App crashes

When debugging on device the App output looks normal except for this line:
MSplcrash_log_writer_init:352: Could not retreive parent process name: Operation not permitted

When I start a debugging session on any simulator I get the same behaviour but these lines instead:

2019-08-07 10:46:22.361135+0200 QuTIP.iOS[13551:79546] [Client] Remote object proxy returned error: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated." UserInfo={NSDebugDescription=The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated.}
2019-08-07 10:46:22.361409+0200 QuTIP.iOS[13551:79546] [Client] Remote object proxy returned error: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated." UserInfo={NSDebugDescription=The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated.}
2019-08-07 10:46:22.361416+0200 QuTIP.iOS[13551:79535] [Client] Sending selectors failed with: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated." UserInfo={NSDebugDescription=The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated.}
2019-08-07 10:46:22.361585+0200 QuTIP.iOS[13551:79535] [Client] Sending selectors failed with: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated." UserInfo={NSDebugDescription=The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated.}
2019-08-07 10:46:22.361588+0200 QuTIP.iOS[13551:79221] [Client] Synchronous remote object proxy returned error: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated." UserInfo={NSDebugDescription=The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated.}
2019-08-07 10:46:22.361761+0200 QuTIP.iOS[13551:79221] [NetworkInfo] Descriptors query returned error: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated." UserInfo={NSDebugDescription=The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated.}
2019-08-07 10:46:22.362254+0200 QuTIP.iOS[13551:79221] [Client] Synchronous remote object proxy returned error: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated." UserInfo={NSDebugDescription=The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated.}
2019-08-07 10:46:22.362306+0200 QuTIP.iOS[13551:79535] [Client] Remote object proxy returned error: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated." UserInfo={NSDebugDescription=The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated.}
2019-08-07 10:46:22.362400+0200 QuTIP.iOS[13551:79221] [NetworkInfo] Descriptors query returned error: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated." UserInfo={NSDebugDescription=The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated.}
2019-08-07 10:46:22.362456+0200 QuTIP.iOS[13551:79546] [Client] Sending selectors failed with: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated." UserInfo={NSDebugDescription=The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated.}
2019-08-07 10:46:22.363000+0200 QuTIP.iOS[13551:79221] [Client] Synchronous remote object proxy returned error: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated." UserInfo={NSDebugDescription=The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated.}
2019-08-07 10:46:22.363090+0200 QuTIP.iOS[13551:79546] [Client] Remote object proxy returned error: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated." UserInfo={NSDebugDescription=The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated.}
2019-08-07 10:46:22.363301+0200 QuTIP.iOS[13551:79221] [NetworkInfo] Descriptors query returned error: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated." UserInfo={NSDebugDescription=The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated.}
2019-08-07 10:46:22.363456+0200 QuTIP.iOS[13551:79535] [Client] Sending selectors failed with: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated." UserInfo={NSDebugDescription=The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated.}

MacOS is 10.14.4
XCode is 10.3
VS Mac is 8.2.2

I have tried catching any exception in Main.cs (iOS project) but no luck.

I updated VC Mac a few days ago and the XCode command line tools yesterday. I was able to keep working as normal until today and I had not rebooted the Mac after the updates. I have tried cleaning everything, removing the app from simulator/device and rebooting the Mac after the errors started to happen but no luck.

Anyone else seeing this?

Is it possible to minimize and maximize the view like Youtube video in Xamarin forms

$
0
0

Is it possible to minimize and maximize the view like Youtube video in Xamarin forms

HttpGet with authorization header

$
0
0

I need to retrieve some json data from web service, specifically FCM, but I can't find how to do that with and authorization header.

I was trying to use the following code:

            var request = (HttpWebRequest)WebRequest.Create(new Uri(url));
            request.ContentType = "application/json";
            request.Method = "GET";

but I can't put the necessary authorization header. I don't find nothing specific and clear of how to do this.

Need help

Xamarin.Forms performance(One MainActivity 80+ ContentPages)

$
0
0

Hi all,

I use xamarin.forms builded an APP, the APP only have one MainActivity class and has more than 80 ContentPages, every ContentPage atleast has one 'Back' button to go to previous page and every page has a override method >>>>protected override bool OnBackButtonPressed() {return true}

When i do testing for about 2 hours, the APP seems run slowly and slowly...

For example, when i done the process in page D, when i press the "Back' button go to C page, do we do some such as clean MEMORY on page D?(if yes, can give me some example code to reference?) or other process to Kill page D?

Can the MainActivity to be restart by some coding without exist the APP? or someone give me some other solutions, many thanks...

I don't have Native Android development experience,i'm a .neter(C#)

How to implement tooltip in android and ios both?

$
0
0

How to implement tooltip in android and ios both?

Xamarin forms Firebase Database to listview

$
0
0

Hello,

I'm trying to get data from Firebase and i got the data and passed it to Listview, but only the count appear on the listview no data. The listview has blank rows.

The Firebase Android that gets the data:

  public void OnDataChange(DataSnapshot snapshot)
        {

            Gson gson = new GsonBuilder().Create();

            var children = snapshot.Children?.ToEnumerable<DataSnapshot>();

            HashMap map = snapshot.Value.JavaCast<HashMap>();

            string vehiclesstring = gson.ToJson(map);

            MessagingCenter.Send<object, string>(this, "vehicles", vehiclesstring);
        }

The Data Reciever:

   private void ToCollection(string data)
    {
        ObservableCollection<Vehicle> Vehicles = new ObservableCollection<Vehicle>();
        Vehicle vehicle = new Vehicle();

        Dictionary<string, object> Data = new Dictionary<string, object>();

        Vehicles.Clear();

        try
        {

            Data = JsonConvert.DeserializeObject <Dictionary<string, object>> (data);

            foreach (KeyValuePair<string, object> item in Data.ToList())
            {
                vehicle = item.Value as Vehicle;
                Vehicles.Add(vehicle);
            }

            vehicleslist.ItemsSource = Vehicles;

        }
        catch (Exception ex)
        {
            DisplayAlert("Error", "Error getting vehicles" + ex.Message, "OK");
        }

    }

The model:

   public partial class Vehicle
  {
    public Vehicle()
    {

    }


    public Vehicle(string key, string imageUri, string model, string plate, string type, string createdAt)
    {
        Key = key;
        ImageUri = imageUri;
        Model = model;
        Plate = plate;
        Type = type;
        CreatedAt = createdAt;
    }

    public string Key { get; set; }
    public string ImageUri { get; set; }
    public string Model { get; set; }
    public string Plate { get; set; }
    public string Type { get; set; }
    public string CreatedAt { get; set; }

}

The Xaml Listview:

  <ListView
                x:Name="vehicleslist"
                ItemSelected="Vehicleslist_ItemSelected"
                RowHeight="80">
            <ListView.ItemTemplate>
                <DataTemplate>
                    <ViewCell Height="50">
                        <StackLayout Margin="10" Padding="0">
                            <Label Text="{Binding Type}" />
                            <Label Text="{Binding Model}" />
                            <Label Text="{Binding Plate}" />
                        </StackLayout>

                    </ViewCell>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>`

How to retain the picker item when app is quit.

$
0
0

Hi,
I have a 3 Language shown below. When I launch my app the default langauge should be English. Also suppose I change language then even If i quit my app and reopen the language shouldn't change (Which ever selected language).
But right now When I launch the app the default language is chinese...even if I change the language nd quit the app and reopen it then also my language is chinese. Please help me in this

xaml.code:

 <Picker   ItemsSource="{Binding PickerList}" SelectedItem="{Binding SelectedItem, Mode=TwoWay}" SelectedIndex="{Binding SelectedIndex, Mode=TwoWay}"/>
<Button Text="Save"/>

view model:

public PageViewModel()
  {
        SelectedItem = CrossMultilingual.Current.CurrentCultureInfo.EnglishName;
        mlanguageArray = new List<SettingsModel>()
        {
            new SettingsModel() { Key = "zh", Value = "Chinese"},
            new SettingsModel() { Key = "en", Value = "English (UK)" },
            new SettingsModel() { Key = "pt", Value = "Portuguese" },
        };

        foreach (SettingsModel val in mlanguageArray)
        {
            mpickerList.Add(val.Value);
        }
        PickerList = mpickerList;
 }

Ho to prevent NSGenericException on iPad

$
0
0

On iPad, when my app attempts to display a notification to the user that a background call to a webservice has been successful, I get the following error:

Foundation.MonoTouchException: Objective-C exception thrown. Name: NSGenericException Reason: Your application has presented a UIActivityViewController (). In its current trait environment, the modalPresentationStyle of a UIActivityViewController with this style is UIModalPresentationPopover. You must provide location information for this popover through the view controller's popoverPresentationController. You must provide either a sourceView and sourceRect or a barButtonItem. If this information is not known when you present the view controller, you may provide it in the UIPopoverPresentationControllerDelegate method -prepareForPopoverPresentation.

I fully realize that the error is telling me to provide a sourceView, etc or to use the prepareForPopoverPresentation method.

What I can't find is where and how exactly to do this, and have been unable to find any helpful examples in C# and Xamarin Forms.

I am fairly new to Xamarin and we had a consultant write this user notification code for us, so I apologize for my lack of understanding, but here's what looks to be the relevant code:

In AppleDelegate.cs:
UNUserNotificationCenter.Current.Delegate = new UserNotificationCenterDelegate();

UserNotificationCenterDelegate Class:
public class UserNotificationCenterDelegate : UNUserNotificationCenterDelegate
{
#region Constructors
public UserNotificationCenterDelegate()
{
}
#endregion

    #region Override Methods
    public override void WillPresentNotification(UNUserNotificationCenter center, UNNotification notification, Action<UNNotificationPresentationOptions> completionHandler)
    {
        // Do something with the notification
        Console.WriteLine("Active Notification: {0}", notification);

        // Tell system to display the notification anyway or use
        // `None` to say we have handled the display locally.
        completionHandler(UNNotificationPresentationOptions.Alert);
    }
    #endregion
}

Creating the notification:
public class CustomSessionUploadDelegate : NSUrlSessionDataDelegate
{ ...
public override void DidCompleteWithError(NSUrlSession session, NSUrlSessionTask task, NSError error)
{
...
var appDelegate = UIApplication.SharedApplication.Delegate as AppDelegate;
appDelegate.ProcessCompletedTask(task);

                bool alertsAllowed = true;
                UNUserNotificationCenter.Current.GetNotificationSettings ((settings) => 
                {
                    alertsAllowed = (settings.AlertSetting == UNNotificationSetting.Enabled);
                });

                if (alertsAllowed == true)
                    this.CreateNotification(headers);
            }...
private void CreateNotification(NSDictionary data)
    {
        lock (thisLock)
        {
            ...
            var content = new UNMutableNotificationContent();
            content.Title = "Image has been uploaded.";
            content.Subtitle = "";
            content.Body = $"Image {document} uploaded successfully.";
            content.Badge = notificationBadge;

            var trigger = UNTimeIntervalNotificationTrigger.CreateTrigger(1, false);

            var requestID = notificationBadge.ToString();
            var request = UNNotificationRequest.FromIdentifier(requestID, content, trigger);

            notificationBadge++;

            UNUserNotificationCenter.Current.AddNotificationRequest(request, (err) =>
            {
                ...

}

Thank you!

Secure socket in Forms

$
0
0

Hello everyone,

I'm developing a Forms application that needs to connect to a java ssl socket using an user certificate. I have defined a DependacyService to split Android and iOS implementation.

I have suceeded in the Android implementation, by prompting the user to select the desired certificate with "KeyChain.ChoosePrivateKeyAlias", then importing it into a KeyStore, to use it in the KeyManager required by SSLSocketFactory.
I'm now trying to do the same in iOS, but I have not found anything that could help me. I have never developed for iOS, and I have just a little Objective C knowledge.

Can anyone give me some tips or guidelines? All I have to do is to let the user select a certificate from his keystore, then use it to open a SSL Socket.

Thank you.

Gradient color on google maps

$
0
0

Hi all,

Is there a way to implement gradient color on google maps in xamarin forms?
I am using Xamarin.Forms.GoogleMaps nugget.

How hide "Title" of child on Tabbed Page

$
0
0

Hi,

with respect to "Title" of child of a Tabbed Page:

If I do not put the title as seen in the following xaml, It looks like this

I want align all the items, included the selected.

My XAML:

Image 1:

<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="#" xmlns:android="clr-namespace:Xamarin.Forms.PlatformConfiguration.AndroidSpecific;assembly=Xamarin.Forms.Core" xmlns:local="clr-namespace:#" android:TabbedPage.ToolbarPlacement="Bottom"> <TabbedPage.Children> <ContentPage IconImageSource="home.png" Title="A" /> <ContentPage IconImageSource="turist.png" /> <ContentPage IconImageSource="map.png" /> </TabbedPage.Children> </TabbedPage>

Image 2:

<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="#" xmlns:android="clr-namespace:Xamarin.Forms.PlatformConfiguration.AndroidSpecific;assembly=Xamarin.Forms.Core" xmlns:local="clr-namespace:#" android:TabbedPage.ToolbarPlacement="Bottom"> <TabbedPage.Children> <ContentPage IconImageSource="home.png" /> <ContentPage IconImageSource="turist.png" /> <ContentPage IconImageSource="map.png" /> </TabbedPage.Children> </TabbedPage>

It can?

how to set X509Certificate2 privatekey?

$
0
0

Hi,
I have an app published from one year ago that use this code to set the privatekey in a x509 certificate:

X509Certificate2 cert = new X509Certificate2(rawData);
RSACryptoServiceProvider privKey = LoadCertificateFile(rawData);
cert.PrivateKey = privKey;

I recently updated the app to solve a bug and I compiled using the latest xamarin version.
The app that now is on the store has problem on the row cert.PrivateKey = privKey; , the error is platform not supported
Googling on internet I found the this method is now discouraged and instead I have to use CopyWithPrivateKey extension method, but it does not work:

X509Certificate2 cert;
using (X509Certificate2 pubOnly = new X509Certificate2(rawData))  
{
    RSACryptoServiceProvider privKey = LoadCertificateFile(rawData);
    using (X509Certificate2 pubPrivEphemeral = pubOnly.CopyWithPrivateKey(privKey))
    {
        cert = new X509Certificate2(pubPrivEphemeral.Export(X509ContentType.Pfx));
    }
}

The problem is that CopyWithPrivateKey is not recognized, the error is:
'X509Certificate2' does not contain a definition for 'CopyWithPrivateKey' and no accessible extension method 'CopyWithPrivateKey' accepting a first argument of type 'X509Certificate2' could be found (are you missing a using directive or an assembly reference?)

Do you have any suggestion?

Thanks in advance

Viewing all 91519 articles
Browse latest View live


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