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

ListView ItemSelected and ItemTapped not working with ContextActions

$
0
0

Hi all.
I have a problem with ListView. I have a viewcell with custom control that has TapGestureRecognizer and it works well. But when I added Context Action to ViewCell ItemSelected stoped working.
What can I do to solve this problem?
Thanks for helping.


Xamarin.Forms CardsView nuget package

$
0
0

Hi all) I've released new package for Xamarin.Forms (Something like Tinder's CardsView)
Maybe, someone will be interested in it

nuget.org/packages/CardsView/ -- nuget
github.com/AndreiMisiukevich/CardView -- source and samples

CarouselView with previewing side elements (Here is how)

Free Hid/USB Cross Platform Library

$
0
0

Listen for connections of USB/Hid (Human Interface Device) devices and communicate with the devices on Android, Windows, and UWP with dependency injection.

https://github.com/MelbourneDeveloper/Device.Net

Here is sample code that works across all platforms:

internal class TrezorExample : IDisposable
{
    #region Fields
    //Define the types of devices to search for. This particular device can be connected to via USB, or Hid
    private readonly List<FilterDeviceDefinition> _DeviceDefinitions = new List<FilterDeviceDefinition>
    {
        new FilterDeviceDefinition{ DeviceType= DeviceType.Hid, VendorId= 0x534C, ProductId=0x0001, Label="Trezor One Firmware 1.6.x", UsagePage=65280 },
        new FilterDeviceDefinition{ DeviceType= DeviceType.Usb, VendorId= 0x534C, ProductId=0x0001, Label="Trezor One Firmware 1.6.x (Android Only)" },
        new FilterDeviceDefinition{ DeviceType= DeviceType.Usb, VendorId= 0x1209, ProductId=0x53C1, Label="Trezor One Firmware 1.7.x" },
        new FilterDeviceDefinition{ DeviceType= DeviceType.Usb, VendorId= 0x1209, ProductId=0x53C0, Label="Model T" }
    };
    #endregion

    #region Events
    public event EventHandler TrezorInitialized;
    public event EventHandler TrezorDisconnected;
    #endregion

    #region Public Properties
    public IDevice TrezorDevice { get; private set; }
    public DeviceListener DeviceListener { get; private set; }
    #endregion

    #region Event Handlers
    private void DevicePoller_DeviceInitialized(object sender, DeviceEventArgs e)
    {
        TrezorDevice = e.Device;
        TrezorInitialized?.Invoke(this, new EventArgs());
    }

    private void DevicePoller_DeviceDisconnected(object sender, DeviceEventArgs e)
    {
        TrezorDevice = null;
        TrezorDisconnected?.Invoke(this, new EventArgs());
    }
    #endregion

    #region Public Methods
    public void StartListening()
    {
        TrezorDevice?.Dispose();
        DeviceListener = new DeviceListener(_DeviceDefinitions, 3000);
        DeviceListener.DeviceDisconnected += DevicePoller_DeviceDisconnected;
        DeviceListener.DeviceInitialized += DevicePoller_DeviceInitialized;
    }

    public async Task InitializeTrezorAsync()
    {
        //Get the first available device and connect to it
        var devices = await DeviceManager.Current.GetDevices(_DeviceDefinitions);
        TrezorDevice = devices.FirstOrDefault();
        await TrezorDevice.InitializeAsync();
    }

    public async Task<byte[]> WriteAndReadFromDeviceAsync()
    {
        //Create a buffer with 3 bytes (initialize)
        var writeBuffer = new byte[64];
        writeBuffer[0] = 0x3f;
        writeBuffer[1] = 0x23;
        writeBuffer[2] = 0x23;

        //Write the data to the device
        return await TrezorDevice.WriteAndReadAsync(writeBuffer);
    }

    public void Dispose()
    {
        TrezorDevice?.Dispose();
    }
    #endregion
} 

Linux, and MacOS support is on its way.

Using IsDescructive in ContextAction produces non clickable items on iOS

$
0
0

Hello,
I have a listview with uneven rows. The items have a typical context action "delete" with the attribute "IsDescructive="true". Now, when I swipe on an item to open the context menu and then cancel the action, the item is not clickable anymore until the listview is realoaded completely.

This is XAML code of my listview:

<ListView x:Name="listView" Margin="0,0,0,0" HasUnevenRows="True" SelectionMode="None" ItemTapped="ListView_ItemTapped" ItemAppearing="ListView_ItemAppearing" BackgroundColor="{StaticResource StandardBackgroundColor}">
    <ListView.ItemTemplate>
        <DataTemplate>
            <ViewCell>
                <ViewCell.ContextActions>
                    <MenuItem Clicked="OnDelete" CommandParameter="{Binding .}" Text="Löschen"  />
                </ViewCell.ContextActions>
                <StackLayout Orientation="Vertical" HeightRequest="90" HorizontalOptions="Fill">
                    <StackLayout Orientation="Horizontal" Margin="10,10,10,0" HorizontalOptions="Fill">
                        <Label Text="{Binding Discipline}" VerticalOptions="Center" HorizontalOptions="StartAndExpand" FontSize="Small" FontAttributes="Bold" TextColor="Black" MaxLines="1"/>
                        <Label Text="{Binding Startdate}" VerticalOptions="Center" HorizontalOptions="End" FontSize="Small" MinimumWidthRequest="100" HorizontalTextAlignment="End" MaxLines="1"/>
                    </StackLayout>
                    <StackLayout Orientation="Horizontal" Margin="10,0,10,0" HorizontalOptions="Fill" >
                        <Label Text="{Binding FinalResult}" VerticalOptions="Center" HorizontalOptions="Start" WidthRequest="50" MinimumWidthRequest="50" FontSize="Medium" TextColor="{StaticResource ColorPrimary}" FontAttributes="Bold"/>
                        <Label Text="{Binding PartResults}" VerticalOptions="Center" HorizontalOptions="StartAndExpand" FontSize="Small"/>
                    </StackLayout>
                    <StackLayout Orientation="Horizontal" Margin="10,0,10,10" HorizontalOptions="Fill">
                        <Label Text="{Binding ActivityType}" VerticalOptions="Center" HorizontalOptions="Start" FontSize="Small" TextColor="Gray" FontAttributes="Bold"/>
                    </StackLayout>
                </StackLayout>
            </ViewCell>
        </DataTemplate>
    </ListView.ItemTemplate>
</ListView>

In the ItemAppearing event I load the model from the database to set the labels via the viewmodel.
The listview ItemSource is set in the constructor of the page and the type is ObservableCollection. So not something special.

As soon as I remove the IsDestructive attribute from the MenuItem, everything works well.

Does someone also have the problem?

How I can rename photo in Xamarin media plugin using PickPhotoAsync

$
0
0

I am working on Xamarin forms. I have notes field; 'Take Photo' button and 'Pick From Gallery' button.

What I want to do is when user take or select photo and click save button; that photo should be renamed as whatever text user type in notes field.

When user take new photo; The text from notes field is getting renamed fine as I wanted.

However, When I select photo from gallery; How I can rename photo to user notes field.
I have researched and tried couple of things but they didn't worked.

This is when user 'Take Photo' and click save button.

       private async void Take_Photo_Button_Clicked(object sender, EventArgs e)
    {
             await CrossMedia.Current.Initialize();
             if (!CrossMedia.Current.IsCameraAvailable || !CrossMedia.Current.IsTakePhotoSupported)
            {
                await DisplayAlert("No Camera", ":( No camera available.", "OK");
               return;
           }
           var file = await CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions
        {
            SaveToAlbum = true,
            Name = jobnoentry.Text + "-" + Applicationletterentry + "-" + signnoentry.Text + "-" + SignType,

        });
        if (file == null)
            return;

        MainImage.Source = ImageSource.FromStream(() =>
        {
            var stream = file.GetStream();
            return stream;
        });

    }

'Name' attribute save the photo to that name.

HOWEVER, When I click 'Pick From Gallery'; I select image; and click save button. How I can Name the image.

The only attributes I get in the 'PickPhotoAsync' or Photo.Size.

This is my code to select from gallery and save.

                                private async void Select_From_Gallery_Button_Clicked(object sender, EventArgs e)
                                {
                                    await CrossMedia.Current.Initialize();
                                    if (!CrossMedia.Current.IsPickPhotoSupported)
                                    {
                                        await DisplayAlert("Photos Not Supported", ":( Permission not granted to photos.", "OK");
                                        return;
                                    }

                                    Stream stream = null;

                                    var file = await CrossMedia.Current.PickPhotoAsync(new Plugin.Media.Abstractions.PickMediaOptions
                                    {

                                       //No attribute for photo name

                                    });

                                    if (file == null)
                                        return;

                                    stream = file.GetStream();
                                    file.Dispose();

                                    MainImage.Source = ImageSource.FromStream(() => stream);


                                }

CMSampleBuffer Attachment Setting

$
0
0

Trying to set DisplayImmediately setting but cannot se how, got so far...

CMSampleBufferAttachmentSettings[] sampleBufferAttachmentSettings = sampleBuffer.GetSampleAttachments(true);
sampleBufferAttachmentSettings[0].DisplayImmediately = true;

Music Isn't playing on IOS

$
0
0

I used this guide: www.youtube.com/watch?v=9h7523oj7nA&feature=youtu.be to learn how to add music to an IOS app on Xamarin. When I run it using the simulator everything works fine and I can hear the music. When I run it on my phone I hear nothing.


What is the best back-end web development language?

$
0
0

What is the best back-end web development language?

Entity Framework Core Sqlite vs SQLite-net-sqlcipher

AppStore Version is not equal to iTunes version

$
0
0

Hi all,

I am using this code to get the "AppStore AppVersion" of my App,

On Feb 2nd I have released an App to AppStore as Version 2.4.3 (Available for users to download), but when I ran my code on Feb 3rd and tried to print console "Version Number @ iTunes ="; I was expecting to see it as 2.4.3 but I see it as 2.4.2 only,

Where could have I gone wrong? I am confused, (I am using this appStoreAppVersion to compare and send an alert to users if they are not on the latest version). (If I am not clear Please ping me in person)

Code Snippet:
{
var dictionary = NSBundle.MainBundle.InfoDictionary;
string applicationID = "org.XYZ";
NSUrl url = new NSUrl($"http://itunes.apple.com/lookup?bundleId={applicationID}");
NSData data = NSData.FromUrl(url);
NSError error = new NSError();
NSDictionary lookup = NSJsonSerialization.Deserialize(data, 0, out error) as NSDictionary;

if (error == null
    && lookup != null
    && lookup.Keys.Length >= 1
    && lookup["resultCount"] != null
    && Convert.ToInt32(lookup["resultCount"].ToString()) > 0)
        {
            var results = lookup[@"results"] as NSArray;

                if (results != null && results.Count > 0)
                {
                    appStoreAppVersion = results.GetItem<NSDictionary>(0)["version"].ToString();

                    Console.WriteLine("Version Number @ iTunes  = " + appStoreAppVersion);
                }
        }

}

Print the finger print

$
0
0

Today's smart phone have finger print scanner for security purposes.
Is it possible to get the finger print from the device and save it as data or image?

Like this:

Thanks in advance :)

System.BadImageFormatException: Method has zero rva

$
0
0

Does anyone here already encountered this error?
"System.BadImageFormatException: Method has zero rva"

So basically, what I'm doing is connecting arduino on a mobile tablet using Serial Port, and This error shows up;
What is the cause of this error?

Retrieve JSON from api in XF

$
0
0

I am learning about Azure Mobile Services and trying to follow along to a slightly older tutorial. I built a simple API backed in asp.net core that returns the following JSON from the URL: https://somebackend.azurewebsites.net/api/todo

[{"id":1,"text":"Item1","isComplete":false}]

I have an on_click method that I am trying to use to retrieve this data.

using Microsoft.WindowsAzure.MobileServices;
.
.
.
private async void Button_OnClicked(object sender, EventArgs e)
{
message.Text = "Loading items...";

        MobileServiceClient client = new MobileServiceClient("https://somebackend.azurewebsites.net/api/todo");
        var items = await client.GetTable<TodoItem>().ReadAsync();
        var item = items.First();

        message.Text = item.Text;

    }

The GetTable line is where everything is breaking. Is that line trying to do a GET request on tables/todoitem ....or is it sending the request from my URL? Am I retrieving this incorrectly? It doesn't work on either Android or iOS simulators, and debugging in VS just says error...but not very helpful. I am not exactly sure how to debug the incoming request from my simulators.

In the attached project, I have the backend that I uploaded to Azure, as well as the Xamarin project.

As for the Webview to allow authentication when you log on the website ?

$
0
0

Пожалуйста, помогите решить эту проблему.
Я использую WebView для открытия веб-сайта.
Сайт использует авторизацию через AD.
При использовании Chrome открывается диалоговое окно авторизации.

При использовании приложения учетные данные не запрашиваются.

Как решить ?


System.Net.WebException: An SSL error has occurred and a secure connection to the server...

$
0
0

Already found the same thread here, but that not resolved my problem.

I have added NSAppTransportSecurity and NSAllowsArbitraryLoads in info.plist.

Screenshot:

enter image description here

Added the below codes from this article.

<key>NSAppTransportSecurity</key>
    <dict>
        <key>NSAllowsArbitraryLoads</key>
        <true/>
        <key>NSExceptionDomains</key>
        <dict>
            <key>pm-admin.smartwcm.com</key>
            <dict>
                <key>NSIncludesSubdomains</key>
                <true/>
                <key>NSExceptionAllowInsecureHTTPSLoads</key>
                <true/>
                <key>NSExceptionRequiresForwardSecrecy</key>
                <true/>
                <key>NSExceptionMinimumTLSVersion</key>
                <string>TLSv1.1</string>
                <key>NSThirdPartyExceptionAllowInsecureHTTPSLoads</key>
                <false/>
                <key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
                <true/>
                <key>NSThirdPartyExceptionMinimumTLSVersion</key>
                <string>TLSv1.1</string>
                <key>NSRequiresCertificateTransparency</key>
                <false/>
            </dict>
        </dict>
    </dict>

I am using HTTP REST APIs. When running the project I am getting the following exception:

System.Net.WebException: An SSL error has occurred and a secure connection to the server cannot be made. ---> Foundation.NSErrorException: Error Domain=NSURLErrorDomain Code=-1200 "An SSL error has occurred and a secure connection to the server cannot be made." UserInfo={NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?

Am I missing something or do anything wrong?

How to put ellipsis for long text in Picker?

$
0
0

How to put ellipsis for long text in Picker?

Any xamarin bluetooth example project? without using any plugin?

$
0
0

Any xamarin Bluetooth example project? without using any plugin?

InitializeComponent does not exist in the current context error

$
0
0

Hi,

The error CS0103 (The name 'InitializeComponent' does not exist in the current context) has started appearing after doing a build of our Xamarin Forms solution. The build, however, appears to have succeeded in spite of this error message?

This started happening after adding the first XAML ContentPage to the PCL project. If I remove the XAML ContentPage then the error disappears.

I've tried installing the latest Alpha channel update on both my Windows (Visual Studio) machine and my Mac build host but it hasn't made any difference.

Please advise ASAP as we would like to use XAML for our ContentPages but may have to revert to using C# code to build the UI if the XAML approach is not viable.

Regards,
Andy

ContextAction Command from custom ViewCell

$
0
0

I have a custom ViewCell which gets selected by a Tempalte Selector.
Now i want that the Command from the ContextAction is executed in the corresponding page ViewModel,
but i don't now how to get the reference to MyPageName.

This is my custom ViewCell:

<?xml version="1.0" encoding="UTF-8"?>
<ViewCell xmlns="http://xamarin.com/schemas/2014/forms" 
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
          xmlns:local="clr-namespace:MyApplication.Converters;assembly=MyApplication"
             x:Class="MyApplication.Pages.Custom.CustomCell">
    <ViewCell.ContextActions>
                                <MenuItem 
                                    Command="{Binding Path=BindingContext.OnSettingsCommand, Source={x:Reference Name=MyPageName}}"
                                    CommandParameter="{Binding .}"
                                    Icon="settings_white.png"
                                    Text="More"/>
                                <MenuItem 
                                    Command="{Binding Path=BindingContext.OnDeleteCommand, Source={x:Reference Name=MyPageName}}" 
                                    CommandParameter="{Binding .}"
                                    Icon="delete.png"
                                    IsDestructive="True"
                                    Text="Delete"/>
                            </ViewCell.ContextActions>
    <ViewCell.View>
        <StackLayout 
                                Orientation="Horizontal" 
                                Padding="10"
                                Spacing="10">
            <StackLayout.Resources>
                <ResourceDictionary>
                    <local:DateConverter x:Key="dateConverter"/>
                </ResourceDictionary>
            </StackLayout.Resources>
            <Image Source="{Binding Image}" />
            <StackLayout Orientation="Vertical" HorizontalOptions="StartAndExpand"
                                             VerticalOptions="Center">
                <Label 
                                            Text="{Binding Title}"  
                                            TextColor="{StaticResource Dark}"
                                            VerticalOptions="End"
                                            Font="Medium, Bold"/>

                <Label 
                                            Text="{Binding CreationDate, Converter={StaticResource dateConverter}}"  
                                            TextColor="{StaticResource grayDark}" 
                                            FontSize="Small" />
            </StackLayout>
            <StackLayout Orientation="Vertical" VerticalOptions="Center">
                <Image Source="{Binding ImageConnectionTypeStatus}"/>
                <Image Source="{Binding ImageSignalStrength}"/>
            </StackLayout>
            <Image Source="arrow_right.png"/>
        </StackLayout>
    </ViewCell.View>
</ViewCell>

Does anybody have an idea ?

Viewing all 204402 articles
Browse latest View live


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