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

how to over come this problem ?

$
0
0

System.InvalidOperationException
Message=You specified a password in the connection string, but the native SQLite library you're using doesn't support encryption.
I am using Microsoft.data.Sqlite for SQLite Database connection, but my Database is Created in system.data.sqlite with password.

Thanks in Advance


How to use PHP Web api in Xamarin Forms

$
0
0

Please Help me in using Php Web Api in Xamarin forms .......

Android crashes after Update to VS 16.7.0

$
0
0

I tested it on two different systems. After I updated vom 16.6.0 oder 16.7.0 I can not start my App anymore. It crashes immediately without giving me any chance to debug anything. On the one System, the Message is just "myApp has stopped" and on the other system not even a message comes up.
The same code runs on a third system with 16.6.0 nicely. I updated all SDK´s and Nuget-packages and tried it with 4 different Android-Systems, even with my Hardware-Device. It is really frustrating. I had so many problems with the last Updates of Xamarin and VS...

Has anyone here had a similar experience? In the net I do not find a message about it.

Xamarin.Forms How to check if View that in Grid that in ScrollView is visible

$
0
0

I have the issue with Grid that is in ScrollView
Some View-s in Grid is out of screen, but when I try get IsVisible for each view inside of Grid it return true ...
But really this View is out of screen ... How to get from code that this View is not visible due to ScrollView ?

Hide Foreground notification

$
0
0

In my android app local notification are triggering using alarmmanager and broadcast receiver, but it's not working in Android 10, So I have implemented foreground service and I am able to get local notification but foreground notification is sticky and can not be removed. Is there any way to hide or remove it from status bar? or is there any other workaround to trigger local notification in android 10.

CheckBox prevent automatic visual setting variable

$
0
0

Hi all,

I curious, is there a way to update state of CheckBox only when it is changed in property ?

Consider the following code:

class SomeObject
{

private bool _somevalue;
public bool IsEnabled
{
get => _somevalue;
set
{
   // _somevalue is not updated immediately, but will be updated later
   // But when setter finished value of CheckBox is set to checked and it is not desired  behavior
}
}

}

In example below I described the issue in details ...

Ant help would be appreciated !!

How can I detect a Bluetooth device disconnect in XF Android?

$
0
0

Using Xamarin Forms 4.1 and this is android specific code for dealing with a BT scanner. I'm connected to a Bluetooth device using BluetoothAdapter, BluetoothDevice and BluetoothSocket. Everything is is working well when the device is powered on and bonded. I'm trying to catch when the device is turned off or out of range etc...

BluetoothAdapter adapter = BluetoothAdapter.DefaultAdapter;
BluetoothDevice device = (from bd in adapter.BondedDevices
                                      where bd.Name == name
                                      select bd).FirstOrDefault();
UUID uuid = UUID.FromString(BluetoothGattServiceUuid);
BluetoothSocket socket;
if ((int) Android.OS.Build.VERSION.SdkInt >= 10) // Gingerbread 2.3.3 2.3.4
{
    socket = device.CreateInsecureRfcommSocketToServiceRecord(uuid);
}
else
{
    socket = device.CreateRfcommSocketToServiceRecord(uuid);
}                                     

var reader = new InputStreamReader(socket.InputStream);
var buffer = new BufferedReader(reader);
char[] chr = new char[100];

while (ct.IsCancellationRequested == false)
{
    // HERE inside this loop I need to know if the device disconnected

    // something was scanned
    if (buffer.Ready())
    {
        // process the barcode
    }
} 

Socket.IsConnected is always true. BluetoothAdapter.State is always On.

So how can I tell when the BT device is no longer there?

Is it possible to execute native script

$
0
0

Hi everyone !
I need to use openCV library but there is no way use library with c# so I was wondering to use another way. I would like to use openCV for Android and iOS, Firstly is there really no c# library openCV ?
Secondly Can I use native script Java (for android) and swift (for iOS) to use openCV

Thank you in advance.


Android release attempting to link Xamarin.IOS.dll

$
0
0

Hi,

I am following the instructions to build and package my APK. I have configured "Link SDK assemblies only" for the Release and the result is the following:

NSUrlSessionDataTaskStream/d__14::MoveNext()' in assembly: 'Xamarin.iOS.dll'

/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(5,5): Error XALNK7000: Mono.Linker.MarkException: Error processing method: 'System.Void System.Net.Http.NSUrlSessionHandler/**NSUrlSessionDataTaskStream/<ReadAsync>d__14::MoveNext()' in assembly: 'Xamarin.iOS.dll'** ---> System.ArgumentNullException: Value cannot be null.
Parameter name: instruction
  at Mono.Cecil.Cil.InstructionOffset..ctor (Mono.Cecil.Cil.Instruction instruction) [0x00021] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/cecil/Mono.Cecil.Cil/Symbols.cs:201 
  at Mono.Cecil.Cil.CodeReader.ReadAsyncMethodBody (Mono.Cecil.Cil.AsyncMethodBodyDebugInformation async_method) [0x0003b] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/cecil/Mono.Cecil.Cil/CodeReader.cs:410 
  at Mono.Cecil.Cil.CodeReader.ReadCustomDebugInformations (Mono.Cecil.MethodDefinition method) [0x00032] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/cecil/Mono.Cecil.Cil/CodeReader.cs:399 
  at Mono.Cecil.Cil.CodeReader.ReadDebugInfo () [0x0004d] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/cecil/Mono.Cecil.Cil/CodeReader.cs:385 
  at Mono.Cecil.Cil.CodeReader.ReadMethodBody () [0x00091] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/cecil/Mono.Cecil.Cil/CodeReader.cs:112 
  at Mono.Cecil.Cil.CodeReader.ReadMethodBody (Mono.Cecil.MethodDefinition method) [0x00014] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/cecil/Mono.Cecil.Cil/CodeReader.cs:59 
  at Mono.Cecil.MetadataReader.ReadMethodBody (Mono.Cecil.MethodDefinition method) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/cecil/Mono.Cecil/AssemblyReader.cs:2120 
  at Mono.Cecil.MethodDefinition+<>c.<get_Body>b__41_0 (Mono.Cecil.MethodDefinition method, Mono.Cecil.MetadataReader reader) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/cecil/Mono.Cecil/MethodDefinition.cs:154 
  at Mono.Cecil.ModuleDefinition.Read[TItem,TRet] (TRet& variable, TItem item, System.Func`3[T1,T2,TResult] read) [0x00040] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/cecil/Mono.Cecil/ModuleDefinition.cs:989 
  at Mono.Cecil.MethodDefinition.get_Body () [0x00026] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/cecil/Mono.Cecil/MethodDefinition.cs:154 
  at Mono.Linker.Steps.MarkStep.ProcessMethod (Mono.Cecil.MethodDefinition method) [0x001aa] in <26f1f288f6da4fe6af38197bae11a23c>:0 
  at Mono.Linker.Steps.MarkStep.ProcessQueue () [0x0001b] in <26f1f288f6da4fe6af38197bae11a23c>:0 
   --- End of inner exception stack trace --- 

The Xamarin.Android project is configured with all the necessary assembly references. Xamarin.IOS is not part of them, of course.

The Debug configuration compiles fine and works perfectly on my test device. May you please advise what to do with this?

Best,
Varban

Exception handling Akavache

$
0
0

Good Day All

I am trying to use

Akavache to store some basic user data so that i dont visit the server all the time . and the implementation is defined on the below link

https://github.com/reactiveui/Akavache#handling-xamarin-linker

in my code i first start Akavache like this

     try
        {
         try
                {
                    Registrations.Start("myapp"); 
                    var user = await BlobCache.Secure.GetObject<USERS>("USER_DATA"); 
                }
                catch (Exception **ex1**)
                { 
            //
                }
    }
        catch (Exception **ex2**)
        { 
            //
        }

as you can see i have a Try catch with the basic Exception handling , My problem here is that if i run the app for the first time obviously there wont be any data in the secure area, the variable "user" i expect it to return null , but what it does it first jump to the Main(ex2) Exception Handling and ruturn to the inner exception handler (ex1)

Thanks

Automapper in Xamarin.Forms took 16 seconds to start the application

$
0
0

Hi!

I have a Xamarin.Forms application that uses AutoMapper plugin to transform some our framework model to a more lightweight mobile model.

I use many profiles and resolvers to do this, but the application takes 16 seconds to starts!

Attached the all AutoMapper files that I use in the application.

What I am doing wrong?

Thank you to all in advice :smile:

Data binding controls in C# code

$
0
0

i have been searching for data binding but instead of being in xaml i am searching for being in .cs file, is there a manner (property) that allows me to bind the specific property to a variable?

Xamarin.Forms.Maps : how to bind the location?

$
0
0

I guess this is a simple binding question: I don't know how to bind x:Arguments...

This is my xaml code:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:d="http://xamarin.com/schemas/2014/forms/design"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:maps="clr-namespace:Xamarin.Forms.Maps;assembly=Xamarin.Forms.Maps"
             mc:Ignorable="d"
             x:Class="AlmicantaratXF.Views.Map">
    <ContentPage.Content>
        <StackLayout>
            <maps:Map x:Name="map"
                      IsShowingUser="True">
                <x:Arguments>
                    <maps:MapSpan>
                        <x:Arguments>
                            <maps:Position>
                                <x:Arguments>
                                    <x:Double>"{Binding Latitude}"</x:Double> <!-- WHAT IS THE CORRECT WAY TO DO THAT? -->
                                    <x:Double>"{Binding StrLat}"</x:Double>
                                </x:Arguments>
                            </maps:Position>
                            <x:Double>0.01</x:Double>
                            <x:Double>0.01</x:Double>
                        </x:Arguments>
                    </maps:MapSpan>
                </x:Arguments>
            </maps:Map>
        </StackLayout>
    </ContentPage.Content>
</ContentPage>

Code behind:

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

using Xamarin.Forms;
using Xamarin.Forms.Xaml;

using AlmicantaratXF.Resources;
using AlmicantaratXF.ViewModels;
using AlmicantaratXF.Model;

namespace AlmicantaratXF.Views
{
    [XamlCompilation(XamlCompilationOptions.Compile)]
    public partial class Map : ContentPage
    {
        public Map(Position position)
        {
            InitializeComponent();
            BindingContext = new MapPageViewModel(position);
        }
    }
}

And View Model:

using AlmicantaratXF.Model;
using System;
using System.Collections.Generic;
using System.Text;

namespace AlmicantaratXF.ViewModels
{
    class MapPageViewModel:BaseViewModel
    {
        public double Latitude { get; set; }
        public double Longitude { get; set; }
        public MapPageViewModel(Position position)
        {
            Latitude = position.Latitude;
            Longitude = position.Longitude;
            OnPropertyChanged("Latitude");
            OnPropertyChanged("Longitude");
        }
    }
}

What is the xaml syntax to bind the Latitude property to the first x:Arguments?
Thanks

Multi-level grouping bindable listview

$
0
0

Hello,

The question is how do we have a multi-level grouped data displayed using list view.

Usually, we would have 'Treeview' for this kind of display, is there any pattern we can follow to display the data using group view.

Here is an example :smile:

Status A

Time 08:00

    Item 1
    Item 2

Status B

Time 12:00

    Item 3
    Item 4

Thank you for the help.

Regards

-Kalpesh

Show Touches (iOS)

$
0
0

Hello,

I am trying to find a way to automatically show touches and gestures (iOS only) like this code is trying to accomplish:

http://forums.xamarin.com/discussion/50254/ios-show-touches-free-library

Seems easy enough to get working, but I have a feeling it wasn't designed for Xamarin Forms projects? Using the above code I can either get the touches to show OR get my app controls to respond to the touches (but never both at the same time).

Has anyone done anything similar? Is there a way to capture all touches (to be handled on one layer - the animation) and then pass the touches along so the app behaves as normal? I am trying to find a way to do it once and have it work with the entire application. I want to try and avoid doing special touch handling and animation on each page separately.

I have also tried using a custom UIWindow (along side the default one) and calling MakeKeyAndVisible(). I had SendEvent overridden and calling window.SendEvent(evt) where 'window' is the default UIWindow that Xamarin Forms creates. However, the touches are not received by the app controls.

I have a feeling I'm misunderstanding something so any help would be appreciated.

Thanks,
Kevin


Switch inside listview get listview item on toggle

$
0
0

I currently have a listview which displays a list of "ConfigurationItem" objects. Each row displays a "ConfigurationItem"'s Name and Status properties in a label and has a Switch hooked up to It's Checked property value.

When I toggle a switch for a listview item I want to get the "ConfigurationItem" for that corresponds with that switch and the value of the switch so I can change the Checked property value for the "ConfigurationItem". Currenlty I've added an eventhandler for the Toggled event which receives the switch as sender but I can't figure out how I can get the "ConfigurationItem" object that corresponds with the toggled switch. Can someone please explain how I can achieve this?

XAML
<ListView x:Name="ConfigurationItemListView" BackgroundColor="Transparent"> <ListView.ItemTemplate> <DataTemplate> <ViewCell> <StackLayout Orientation="Horizontal"> <StackLayout Orientation="Vertical"> <Label Text="{Binding Name}" TextColor="#fff" HorizontalOptions="FillAndExpand" FontAttributes="Bold"/> <Label Text="{Binding Status}" HorizontalOptions="FillAndExpand" TextColor="#fff" FontSize="Micro"/> </StackLayout> <Switch IsToggled="{Binding Checked}" HorizontalOptions="EndAndExpand" Toggled="OnItemToggled"/> </StackLayout> </ViewCell> </DataTemplate> </ListView.ItemTemplate> </ListView>

C#
private Room currentRoom { get; set; } public ConfigurationItemPage() { InitializeComponent(); }

//Room selected public ConfigurationItemPage(Room room) { InitializeComponent(); currentRoom = room; this.Title = currentRoom.Name; GetConfigurationItems(); MessagingCenter.Subscribe<ConfigurationItemDetailsPage>(this, "GetConfigurationItems", (sender) => GetConfigurationItems()); ConfigurationItemListView.ItemSelected += OnItemSelected; }

async void OnItemSelected(object sender, SelectedItemChangedEventArgs e) { if (ConfigurationItemListView.SelectedItem != null) { await Navigation.PushModalAsync(new ConfigurationItemDetailsPage((ConfigurationItem)e.SelectedItem)); } ((ListView)sender).SelectedItem = null; }

public void OnItemToggled(object sender, ToggledEventArgs e) { //Get ConfigurationItem (listview item) //save switch value Switch toggledSwitch = (Switch)sender; }

public async void GetConfigurationItems() { LoadingActivityIndicator.IsRunning = true; LoadingActivityIndicator.IsVisible = true; ConfigurationItemService configurationItemService = new ConfigurationItemService(); IEnumerable<ConfigurationItem> configurationItems = await configurationItemService.GetByRoomId(currentRoom.Id); ConfigurationItemListView.ItemsSource = configurationItems; LoadingActivityIndicator.IsRunning = false; LoadingActivityIndicator.IsVisible = false; }

Validation doesn't work after xamarin.forms update package

$
0
0

Before I have already done an update to the nuget package Xamarin.Forms, my application worked correctly, when I clicked on the button "Sacuvaj", if I had errors, it would print a certain message. After the update package, when I click on the button "Sacuvaj", the message is not printed and the background becomes light blue. Also the redirect doesn't work, while in the previous version everything worked properly. Where is the problem?

Create share button

$
0
0

Hello,
is there a way to create a "Share" button with Forms?
I want to create this button that, when pressed, launches the classic intent chooser in Android (Image 1), the UIActivityViewController in iOs (Image 2) and... what is it for Windows Phone?


is there a Tabbed view in Xamarin.forms?

$
0
0

Hello,
any idea how to make a Tabbed view in xamarin.forms,
i only found Tabbed page which is not possible to put it inside a content page!

choosing Xamarin.forms is bad choice? should i've used each platforme beside with xamarin.android and xamarin.ios!

Thanks in advance

Rotate a ContentPage 90 degrees (Render landscape)

$
0
0

Hi,

I want to force a specific ContentPage page to be rendered in landscape mode (Rotated 90).
This is not the same allowing the user to rotate the phone and the content adjusts, I need to force the content to be rendered in landscape regardless of orientation etc.

I can somewhat achieve this by setting the Rotation property to 90 however the issues start as the Height and Width of the views have been calculated then it is rotated leaving you with views that now extend outside the width and all sorts of weird and wonderful issues.

I have tried the below, it did not force the device into landscape mode...

https://stackoverflow.com/questions/29057972/xamarin-forms-on-ios-how-to-set-screen-orientation-for-page

How to do make Xamarin render landscape mode on a view when the device is held in portrait.

Viewing all 79144 articles
Browse latest View live