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

ListView separators on only some rows

$
0
0

I have a Master/Detail application where the menu is mostly alphabetized, but Settings and Log Out are at the bottom. I'm using a ListView for the master page's menu. The UI requirement is to put a separator above the non-alphabetical items. So I need a separator above settings and above logout. Like this:

Add
Delete
Edit
Probe
Whatever
(separator)
Settings
(separator)
Log Out

But I don't want a whole row for the separators. Really what I want to do is modify SeparatorColor on the ListView for just a couple items. Is that possible? I'm trying to use a 1px BoxView but then my menu items aren't evenly centered in the ListView and that doesn't look great.

Here's what my viewcell looks like. The background color and label color are so that I can color the frame of the active menu item, because the default selected item color stuff is gross.

edit: apologies, I cannot figure out how to format the XAML block to look good on the forums.

<ViewCell> <ViewCell.View> <StackLayout VerticalOptions="Fill"> <Frame BackgroundColor="{Binding BackgroundColor}" VerticalOptions="Start" BorderColor="{Binding BackgroundColor}" CornerRadius="3" HasShadow="False" HeightRequest="40" Margin="8,4,8,4"> <Frame.Content> <Grid VerticalOptions="Center" HorizontalOptions="Fill" BackgroundColor="{Binding BackgroundColor}"> <Grid.ColumnDefinitions> <ColumnDefinition Width="48"/> <ColumnDefinition Width="*"/> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="*"/> </Grid.RowDefinitions> <Image Grid.Column="0" Source="{Binding TileIcon}" Aspect="AspectFit" HeightRequest="24" VerticalOptions="Center" HorizontalOptions="Start" /> <Label Grid.Column="1" Text="{Binding PortalName}" Style="{StaticResource menuItem}" VerticalOptions="Center" TextColor="{Binding LabelColor}" /> </Grid> </Frame.Content> </Frame> </StackLayout> </ViewCell.View> </ViewCell>


Weird error when I compile : IBTool exited with code 255

$
0
0

Hi,

using Visual studio comunity version 7.4.1, on Macos high sierra 10.13.3
I got on github a sample of RSS reader : https: // github.com/Mahabali/XamarinRSSFeed

when I compile, at first : I can run it.

the IOS project target IOS 10.0
the droid project target latest android 8.1

then, all package needed to be updated.
si I updated all package,
and now, I have 2 errors, which (for me) are not telling me what is wrong :
IBTool exited with code 255
the "IBTool" task failed unexpectedly

I tried to delete all bin and obj, and I tried to clean ll before build, without success.

what can I do ?
except delete visual studio, nuget packages, and reinstall everything ? (this is not an option for me :o)

thanks
Olivier

HotReload LiveReload LiveXaml [Mac] [Windows] [nuget package] [opensource]

I am working on a project where I need to Implement CoverFlow.

$
0
0

I am working on a project where I need to Implement CoverFlow with Three images in left right and centre.

Long label with word wrap doesn't seem to auto calculate height correctly

$
0
0

I have a label within a flex layout that doesnt seem to adjust to the new height of a wrapped label. Is this a bug or am I missing something?

This is within a stack layout

There is still another full sentence after this that wont show up unless I manually enter a HeightRequest larger

await HttpClient.PostAsync() reports System.NullReference but HttpClient.PostAsync().Result doesn't

$
0
0

Hi all,

in my app I need to check if user is logged in. We are using Oath2 and I only want to check if refresh token is valid.
I do this in OnStart method. I have simplified the code a bit but the exception is still thrown in

var response = await httpClient.PostAsync(url, content); 

if I replace it with:

var response = httpClient.PostAsync(url, content).Result; 

then the crash does not happen. What am I missing ?

App.xaml.cs

protected override async void OnStart()
    {
        // Handle when your app starts

        try
        {
            RefreshToken refreshToken = new RefreshToken((Application.Current as App).RefreshToken);

            var haveValidRefreshToken = await IsRefreshTokenValid();
            if (haveValidRefreshToken.IsSuccess)
                MainPage = new NavigationPage(new LoginPage());
            else
                MainPage = new NavigationPage(new Views.MainTabbedPage());
        }
        catch ( UserServiceException )
        {
            MainPage = new NavigationPage(new LoginPage());
        }
    }

    static async Task<RestResponse> IsRefreshTokenValid()
    {
        var content = new StringContent("", Encoding.UTF8, "application/json");
        var httpClient = new HttpClient();
        string url = "13.74.21.155:8080";
        var response = await httpClient.PostAsync(url, content);    // <==== System.NullReference thrown
        return new RestResponse
        {
            IsSuccess = response.IsSuccessStatusCode,
            Status = response.StatusCode,
            Content = await response.Content.ReadAsStringAsync()
        };
    }

Xamarin.forms Pinch gesture to zoom inside a carousel - conflict swipe/pan

$
0
0

Hi,
After weeks of try and fix, i was able to have a working pinch gesture on an image inside a carousel page. Now the last problem i have is that the carousel catches the pan gestures on the zoomed image as a pinch navigation gesture and slides to the next image. My approach is to ignore gestures on the carousel as long as the image inside is zoomed. Pushing the user to zoom out to the normal scale and than swipe to the next page.
How can i achieve this knowing that the InputTransparent disables gestures for both the carousel and its children ?

PS: This behaviour happens only on Android. On IOS it's working as wanted.

Read firebase push notification to local

$
0
0

Hi Team,

How to Read a firebase notifications to app local no sql db?


What is the best way to backup/restore files?

$
0
0

Hello
I want my users to backup or restore manually a SQLite database file and other data files, what is the best way to do that?
My app is a xamarin.forms PCL for three platforms.

Thank you for your help
rubenc

Can't detect back button when showing camera screen

$
0
0
public partial class TakePhotoPage
{
    private bool _firstLoading =true;~~~~~~~~~~~~
    protected override void OnAppearing()
            {
                if (_firstLoading)
                {
                    TakePicture();
                    _firstLoading = false;
                }
                if (backEvent == 1)
                {
                    base.OnAppearing();
                    DependencyService.Get<IOrientationService>().SetOrientation(DeviceOrientation.Portrait);
                }
            }

            protected override void OnDisappearing()
            {
                base.OnDisappearing();
                DependencyService.Get<IOrientationService>().SetOrientation(DeviceOrientation.Portrait);
            }

            async void TakePicture()
            {
                viewModel.IsBusy = true;
                await CrossMedia.Current.Initialize();
                viewModel.IsBusy = false;
                if (!CrossMedia.Current.IsTakePhotoSupported)
                {
                    return;
                }
                string prefix = DateTime.Today.ToString("dd-MM-yyyy");
                var file = await CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions
                {
                    SaveToAlbum = true,
                    SaveMetaData = true,
                    Directory = prefix,
                    MaxWidthHeight = 1650,
                    CompressionQuality = 75
                }); // show camera here

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

i try override some method to detect back button. but it's only working when click back button at TakePhotoPage, in camera screen , it's not working.
Have anything detect when click back button at camera screen ?????? I want detect to redirect to another page when click back button in camera screen(not back button of navigation bar)- Need Android & IOS Pls

Thanks All.

How to detect text and search a location over mapview?

$
0
0

I added mapview using xamarin.forms.maps package. I wanted to add a searchbar field to search address and drop pin using search box.

How to add a SearchBar programmatically a search a location?

I tried the following:

var searchField = new SearchBar
{
Placeholder = "Enter search term"
};
searchField.SearchCommand = new Command(() => { if (searchField != null) { string.Format("Result: {0} is what you asked for.", searchField.Text); }
** // I don't get the text here**

Content = new StackLayout
{
Spacing = 0,
Children = {
searchField,
map,
buttons
}
};

Visual Studio Professional 2017 and Xamarin Forms - Build Issue

$
0
0

VS Professional 2017 Version 15.7.4 (On Windows 10)
Xamarin.Forms - 3.0

Platform Target Frameworks:
iOS: 11.12.0.4
Android: 8.3.3.2
UWP: N/A

If i try to create a Xamarin.Forms (3.1) project in Visual Studio 2017, it fails with below issues.

Severity Code Description Project File Line Suppression State
Error MSB4062 The "Xamarin.Forms.Build.Tasks.XamlGTask" task could not be loaded from the assembly C:\Users\nmansuri.nuget\packages\xamarin.forms\3.0.0.561731\build\netstandard2.0\Xamarin.Forms.Build.Tasks.dll. Could not load file or assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified. Confirm that the declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. July7App C:\Users\nmansuri.nuget\packages\xamarin.forms\3.0.0.561731\build\netstandard2.0\Xamarin.Forms.targets 75

Severity Code Description Project File Line Suppression State
Error MSB4062 The "Xamarin.Forms.Build.Tasks.GetTasksAbi" task could not be loaded from the assembly C:\Users\nmansuri.nuget\packages\xamarin.forms\3.1.0.583944\build\netstandard2.0\Xamarin.Forms.Build.Tasks.dll. Could not load file or assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified. Confirm that the declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. July7App C:\Users\nmansuri.nuget\packages\xamarin.forms\3.1.0.583944\build\netstandard2.0\Xamarin.Forms.targets 36

Another observation is the warning symbol appearing on the Dependencies folders in the shared library project. I dont understand why it appears.

Steps to Reproduce
Create a new Blank Forms Project - choose only android and ios target projects and code
sharing strategy is set to .NET standard
Without making any changes to the default structure, Build or clean solution
the above mentioned errors are thrown

Intellisense does not seem to work properly in VS for Mac 2019

$
0
0

I've recently upgraded to VS for Mac 2019. Have just created a vanilla project using Xamarin.Forms 3.6.0.264807 and Xamarin.Essentials 1.0.1.

Intellisense does not appear to work properly when I'm editing a XAML file. See image below.

There should be more options that appear in the list. Also, there is no error highlighting (if I try and set a property on Button called Foo for instance).

How to display Gregorian date in DatePicker instead of Hijri when culture is Arabic?

$
0
0

My app is dual-language, English and Arabic, and when the culture is set to Arabic the date shows as Hijri. How can I force the datepicker to show the Gregorian date?

App logs out when it goes to background

$
0
0

Hi All,
My App has login and when it goes to background, it is automatically getting logout in both android and iOS as well .
So can anyone Please help me.


Vertical slider takes horizontal space as lenght?

$
0
0

Hey Guys,
I am working since yesterday with xamarin and and xaml. I have a specific layout in my mind and tried this:

!--Mobile-->
-Label Grid.Row="0" x:Name="mLabel" Text="Mobile" HorizontalTextAlignment="Center" FontSize="32"/>
-Grid Grid.Row="1">
--Grid.ColumnDefinitions>
---ColumnDefinition Width="25"/>
---ColumnDefinition Width="10
"/>
---ColumnDefinition Width="65"/>
--/Grid.ColumnDefinitions>
--Grid.RowDefinitions>
---RowDefinition Height="
" />
--/Grid.RowDefinitions>

--Slider Grid.Row="0" Grid.Column="1" x:Name="mSlider" Maximum="100" Value="75" Minimum="0" ValueChanged="mSlider_ValueChanged" Rotation="-90"/>
--Image Grid.Row="0" Grid.Column="2" VerticalOptions="Start" Source="{local:ImageResource Doja.Images.Battery.png}"/>
-/Grid>

The problem is that the slider is only as long as the 10* width (thats my guess). :/ I want it to be as big as the image (the grid cell height)

PS: Can someone explain me how to post Xaml correctly mine disappears?

Vertical Slider

$
0
0

Hey Guys thanks in advance!
So I need a vertical slider. I only found this option but can't apply it on my Xamarin.forms slider! Please help.
https://forums.xamarin.com/discussion/3007/custom-vertical-uislider-example-anywhere

What I tried:
Step1: Rotation - Does not work because the slider will take the width of the Layoutbox anyway!
Step2: Stacklayout.Orientation - Does strange things.
Step3: CustomSlider - But there are not enough exposed settings achieve what I want!

class CustomSlider : Slider
    {
        public CustomSlider()
        {
            this.BackgroundColor = Color.Red;
            //this.Rotation = -90;
            //this.AnchorX = 0.5;
            //this.AnchorY = 0.5;

            System.Diagnostics.Debug.WriteLine(" ");
            System.Diagnostics.Debug.WriteLine(" ");
            System.Diagnostics.Debug.WriteLine(" ");
            System.Diagnostics.Debug.WriteLine(">> CUSTOM SLIDER: ID " + this.Id);
            System.Diagnostics.Debug.WriteLine(">> CUSTOM SLIDER: Bounds " + this.Bounds.ToString());
            System.Diagnostics.Debug.WriteLine(">> CUSTOM SLIDER: AnchorX " + this.AnchorX.ToString());
            System.Diagnostics.Debug.WriteLine(">> CUSTOM SLIDER: AnchorY " + this.AnchorY.ToString());
            System.Diagnostics.Debug.WriteLine(">> ");
            System.Diagnostics.Debug.WriteLine(">> CUSTOM SLIDER: RequestH " + this.HeightRequest);
            System.Diagnostics.Debug.WriteLine(">> CUSTOM SLIDER: RequestW " + this.WidthRequest);
            System.Diagnostics.Debug.WriteLine(">> CUSTOM SLIDER: Height " + this.Height);
            System.Diagnostics.Debug.WriteLine(">> CUSTOM SLIDER: Width " + this.Width);
            System.Diagnostics.Debug.WriteLine(">> ");
            System.Diagnostics.Debug.WriteLine(">> CUSTOM SLIDER: VOptionsA " + this.VerticalOptions.Alignment);
            System.Diagnostics.Debug.WriteLine(">> CUSTOM SLIDER: HOptionsA " + this.HorizontalOptions.Alignment);
            System.Diagnostics.Debug.WriteLine(">> ");
            System.Diagnostics.Debug.WriteLine(">> CUSTOM SLIDER: VOptionsE " + this.VerticalOptions.Expands);
            System.Diagnostics.Debug.WriteLine(">> CUSTOM SLIDER: HOptionsE " + this.HorizontalOptions.Expands);
            System.Diagnostics.Debug.WriteLine(">> ");
            System.Diagnostics.Debug.WriteLine(">> CUSTOM SLIDER: Scale " + this.Scale);
            System.Diagnostics.Debug.WriteLine(">> CUSTOM SLIDER: RotX " + this.RotationX);
            System.Diagnostics.Debug.WriteLine(">> CUSTOM SLIDER: RotY " + this.RotationY);
            System.Diagnostics.Debug.WriteLine(">> CUSTOM SLIDER: RotZ " + this.Rotation);
            System.Diagnostics.Debug.WriteLine(">> ");
            System.Diagnostics.Debug.WriteLine(">> CUSTOM SLIDER: TransX " + this.TranslationX);
            System.Diagnostics.Debug.WriteLine(">> CUSTOM SLIDER: TransY " + this.TranslationY);
            System.Diagnostics.Debug.WriteLine(">> CUSTOM SLIDER: XPos " + this.X);
            System.Diagnostics.Debug.WriteLine(">> CUSTOM SLIDER: YPos " + this.Y);
            System.Diagnostics.Debug.WriteLine(" ");
            System.Diagnostics.Debug.WriteLine(" ");
            System.Diagnostics.Debug.WriteLine(" ");
        }
    }

How can I make myself a slider that can be vertical from bottom to top, filling my Layout-Grid-Cell?
Or has someone an example? The XLabs ExtendedSlider does not have a vertical setting as well if I am correct.

Custom slider control

How to use a service. Error "Check whether the service is registered in the AndroidManifest"

$
0
0

Dear all,
I am a beginner in Xamarin and I am trying to develop my first Android app.
I have to use a third party SDK to connect and receive data from a barcode scanner via bluetooth.
I created a new Xamarin.Forms project and a new Library binding android project.
I followed the poor documentation for the SDK but when I call a function which should search for bluetooth devices, I get this error:

{Java.Lang.IllegalStateException: Check whether the service is registered in the AndroidManifest
  at Java.Interop.JniEnvironment+InstanceMethods.CallVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00069] in <286213b9e14c442ba8d8d94cc9dbec8e>:0 
  at Android.Runtime.JNIEnv.CallVoidMethod (System.IntPtr jobject, System.IntPtr jmethod, Android.Runtime.JValue* parms) [0x0000e] in <b781ed64f1d743e7881ac038e0fbdf85>:0 
  at Com.Bim.Bluetooth.Manager.SearchScanner (Com.Bim.Interfaces.IOnSearchCallback onSearchCallback) [0x0005c] in C:\ProgettiVS\TestJar\PosunitechScanner\obj\Debug\generated\src\Com.Bim.Bluetooth.Manager.cs:248 
  at TestJar.Droid.MainActivity.OnCreate (Android.OS.Bundle savedInstanceState) [0x00031] in C:\ProgettiVS\TestJar\TestJar\TestJar.Android\MainActivity.cs:43 
  --- End of managed Java.Lang.IllegalStateException stack trace ---
java.lang.IllegalStateException: Check whether the service is registered in the AndroidManifest
    at com.bim.bluetooth.Manager.checkBinder(Manager.java:117)
    at com.bim.bluetooth.Manager.searchScanner(Manager.java:46)
    at md59d3085c099eda7a3b5de2c6cfaef6eaa.MainActivity.n_onCreate(Native Method)
    at md59d3085c099eda7a3b5de2c6cfaef6eaa.MainActivity.onCreate(MainActivity.java:29)
    at android.app.Activity.performCreate(Activity.java:7136)
    at android.app.Activity.performCreate(Activity.java:7127)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1272)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2899)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3054)
    at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1814)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:280)
    at android.app.ActivityThread.main(ActivityThread.java:6706)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
}

This is my Manifest, as suggested in the documentation I added permissions and enabled the service.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="-----schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.companyname.TestJar.Android">
  <uses-permission android:name="android.permission.BLUETOOTH" />
  <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
  <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
  <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
  <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />

  <uses-sdk android:minSdkVersion="21" android:targetSdkVersion="27" />
    <application android:label="TestJar.Android">
      <service
            android:name="com.bim.bluetooth.BluetoothService"
            android:enabled="true" />
    </application>
</manifest>

Is the error related to the com.bim.bluetooth.BluetoothService service?
Did I register the service in the right way?

I have a test project if you want to see it, just ask me.

Thank you in advance

Fabio

How to access ContentView objects (x:Name) when you include this contentview in a page?

$
0
0

Hello,

I got this page:

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="Manager.Pages.EstablishmentCreateUser"
             xmlns:local="clr-namespace:APP.Views;assembly=APP"
             Title="Create user">
    <local:UserInfos/>
</ContentPage>

And i got this ContentView:

<?xml version="1.0" encoding="UTF-8"?>
<ContentView xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="APP.Views.UserInfos">
    <ContentView.Content>
        <StackLayout Orientation="Vertical">
            <Entry x:Name="E_Firstname" Placeholder="Prénom"/>
            <Entry x:Name="E_Lastname" Placeholder="Nom"/>
            <Entry x:Name="E_RegistrationNumber" Placeholder="Matricule"/>
            <Entry x:Name="E_Phone" Placeholder="Téléphone fixe"/>
            <Entry x:Name="E_Mobile" Placeholder="Téléphone mobile"/>
            <Entry x:Name="E_Email" Placeholder="Adresse électronique"/>
            <Entry x:Name="E_Adress" Placeholder="Adresse du domicile"/>
            <Picker x:Name="P_Job"/>
            <Picker x:Name="P_WeeklyHours"/>
            <StackLayout Orientation="Horizontal">
                <Label x:Name="L_Intermittent" Text="Intermittent"/>
                <Switch x:Name="S_Intermittent"/>
            </StackLayout>
        </StackLayout>
    </ContentView.Content>
</ContentView>

My design works fine but i'm trying to access :xName entries from my ContentView when i'm in my Page.
How i can access it?

Best regards

Viewing all 77050 articles
Browse latest View live


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