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

Error during release build

$
0
0

Unerwarteter Fehler bei der LinkAssemblies-Aufgabe.
Mono.Linker.MarkException: Error processing method: 'Android.Views.ScaleGestureDetector Xamarin.Forms.Platform.Android.GestureManager::InitializeScaleDetector()' in assembly: 'Xamarin.Forms.Platform.Android.dll' ---> Mono.Cecil.ResolutionException: Failed to resolve System.Void Android.Support.V4.View.ScaleGestureDetectorCompat::SetQuickScaleEnabled(Android.Views.ScaleGestureDetector,System.Boolean)
bei Mono.Linker.Steps.MarkStep.HandleUnresolvedMethod(MethodReference reference)
bei Mono.Linker.Steps.MarkStep.MarkMethod(MethodReference reference)
bei Mono.Linker.Steps.MarkStep.MarkInstruction(Instruction instruction)
bei Mono.Linker.Steps.MarkStep.MarkMethodBody(MethodBody body)
bei Mono.Linker.Steps.MarkStep.ProcessMethod(MethodDefinition method)
bei Mono.Linker.Steps.MarkStep.ProcessQueue()
--- Ende der internen Ausnahmestapelüberwachung ---
bei Mono.Linker.Steps.MarkStep.ProcessQueue()
bei Mono.Linker.Steps.MarkStep.ProcessPrimaryQueue()
bei Mono.Linker.Steps.MarkStep.Process()
bei MonoDroid.Tuner.MonoDroidMarkStep.Process(LinkContext context)
bei Mono.Linker.Pipeline.Process(LinkContext context)
bei MonoDroid.Tuner.Linker.Process(LinkerOptions options, ILogger logger, LinkContext& context)
bei Xamarin.Android.Tasks.LinkAssemblies.Execute(DirectoryAssemblyResolver res)
bei Xamarin.Android.Tasks.LinkAssemblies.Execute()
bei Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
bei Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext() Retailer.Android

Hello,
my code shows this error trying to build a release version.

Can someone explain me what
s happend?


Two buttons, fill width of both if first is disabled

$
0
0

I have two buttons arranged horizontally, if either buttons is disabled, I would like to take the full width. The following code works if both buttons IsEnabled="True", how would I take up the entire space if one is disabled? Not opposed to using a StackLayout either.

<Grid>
    <Grid.ColumnDefinations>
        <ColumnDefination Width="*"/>
        <ColumnDefination Width ="*"/>
    </Grid.ColumnDefinations>
    <Button Grid.Row ="0" Grid.Column="0" Text="B1" HorizontalOptions="FillAndExpand"/>
    <Button Grid.Row ="0" Grid.Column="1" Text="B2" HorizontalOptions="FillAndExpand"/>
</Grid>

Shell does not work with TabbedPage in IOS

$
0
0

Hi

I'm using Shell with buttom nav and want to be able to have one of the tabs as a TabbedPage. Also one of my contentpages in Shell have a toolbar item which leads to a tabbedpage, this also does not work in iOS, but both working fine in Android.

What I mean by not working is that even though I set the background color to white, I just get a black "blank-screen", I see nothing.

I tried to create a new TabbedPage, same issue, tryed the newest 3.6 forms release and also the 4.0 beta 9pre release, still same issue.

Does anyone have a workaround for this?

Overriding OnDisappearing

$
0
0

I have a non modal page where the user enters data. If the user clicks the software back button (popping the task) before saving his entered data I want to ask the user if they want to save the data.

I can do this by overriding OnDisappearing like so:
async protected override void OnDisappearing () { //base.OnDisappearing (); if (UnsavedData ()) { bool answer = await DisplayAlert ("Unsaved Changes", "Would you like to save your changes?", "Yes", "No"); if (answer) { PersistChanges (); } } }
The problem I am running into is that before PersistChanges is called, my code returns to previous screen.
What can I do to delay the pop until after PersistChanges executes?

Thank you.

Shell does not work with TabbedPage in IOS

$
0
0

Hi

I'm using Shell with buttom nav and want to be able to have one of the tabs as a TabbedPage. Also one of my contentpages in Shell have a toolbar item which leads to a tabbedpage, this also does not work in iOS, but both working fine in Android.

What I mean by not working is that even though I set the background color to white, I just get a black "blank-screen", I see nothing.

I tried to create a new TabbedPage, same issue, tryed the newest 3.6 forms release and also the 4.0 beta 9pre release, still same issue.

Does anyone have a workaround for this?

Why is the group header different in ios and android?

$
0
0

I am using the collection view component to create a calendar and group the days by months and the information of the months I use it to build a header, but in ios it does not take the form I give it.

Data binding and passing object to custom control.

$
0
0

Let say I created a custom control to replace

<ContentView BackgroundColor="{Binding Blah.Type}">
    <Label Text="{Binding Blah.Name}" TextColor="{Binding Blah.Color}" />
</ContentView>

by

<local:CustomLabel Text="{Binding Person.Name}" Type="{StaticResource inverse}" />

So my custom label xaml would look like:

<?xml version="1.0" encoding="utf-8" ?>
<ContentView xmlns="http://xamarin.com/schemas/2014/forms" x:Class="Blah.CustomLabel" 
    BackgroundColor="{Binding Type}">
    <Label x:Name="Label2" Text="{Binding Text}" TextColor="{Binding TextColor}" />
</ContentView>

and my custom label class would look like:

public partial class CustomLabel : ContentView {

        public CustomLabel()
        {
            InitializeComponent();
            BindingContext = this;
        }

        public static readonly BindableProperty TextProperty =
            BindableProperty.Create("Text", typeof(string), 
                typeof(CustomLabel), string.Empty);

        public string Text
        {
            get { return (string)GetValue(TextProperty); }
            set{ SetValue(TextProperty, value); }
        }

        public static readonly BindableProperty TextColorProperty =
            BindableProperty.Create("TextColor", typeof(Color), typeof(CustomLabel), Color.FromHex("#fff"));

        public Color TextColor
        {
            get { return (Color)GetValue(TextColorProperty); }
            set{ SetValue(TextColorProperty, value); }
        }

        public static readonly BindableProperty TypeProperty =
           BindableProperty.Create("Type", typeof(Color), typeof(CustomLabel), Color.FromHex("#999"));

        public Color Type
        {
            get { return (Color)GetValue(TypeProperty); }
            set { SetValue(TypeProperty, value); }
        }
    }

I set BindingContext = this to force the ContentView BindingContext to be this view so the binding work.
I can add this custom control to my view by

<local:CustomLabel Text="Something!" TextColor="Red" />

This work just fine, my problem is when passing or attach a bindable object to the custom control. Ex:

<local:CustomLabel Text="{Binding Person.Name}" TextColor="Red" />

The TextProperty always null.

iOS app crashes with no explanation when CollectionView set to horizontal

$
0
0

Hi!
I was having a bit of a strange issue, and was wondering if anyone would be kind enough to guide me in the right direction.
I have a cross platform Xamarin app that runs on both iOS and Android. Recently I started using CollectionView, and found that whenever a CollectionView with the following configuration was rendered:

<CollectionView.ItemsLayout
<GridItemsLayout Orientation="Horizontal"
</CollectionView.ItemsLayout

The iOS app would crash right away. Android works fine, and setting it to vertical prevents the crash on iOS, but I don't think it's crazy to suggest this shouldn't happen.
Does anyone happen to know what's going on?

Thank you in advance.

(Sorry about the missing closing tags, they seem to make the second line of code disappear in this markdown editor?)


How to get Details property from a TextCell in UITest?

$
0
0

Hi, we're just starting on our first Xamarin app.
We've got a view which uses TextCells to display information about a person and binds the value to the Detail property
as an example <TextCell Text="Age:" AutomationId="age" Detail="{Binding Information.Age}" TextColor="DimGray" DetailColor="Black" />

If I retrieve the control with app.Query("age").FirstOrDefault() I don't get the content of the control

REPL tree shows me
[TextCellRenderer_TextCellView > LinearLayout] label: "age"
[TextView] text: "Age:"
[TextView] text: "40"
[View]

Is there any way of getting the Details value?

Thanks.

Developing a Location Background Service

$
0
0

Hi

I want my app to send a location every x minuttes, both when using the app, but also when the app is in the background.

I seen a few example of how to create a service which is running in the background with xamarin.android. (https://github.com/xamarin/mobile-samples/tree/master/BackgroundLocationDemo)

But what about xamarin.forms, which I'm working on? Could the same code be used with forms? Also I haven't seen the same for xamarin.ios.

Why can't I find a full example code of sending locations from a app, both foreground and background? I'm convinced a lot of developers could be interested in such functionallity.

I'm very new to xamarin, so I'm hoping you can point me in the right direction if its possible to develop such funcionallity.

Kind regards

Is anyone actually using the geofence plugin in production?

$
0
0

I have created an app that uses the geofence plugin (https://github.com/domaven/xamarin-plugins/tree/master/Geofence) to notify users when they enter/exit certain locaitons.

It works to some extent, but there are a few problems:
-When monitoring location exit, iOS users experience numerous false exit notifications, especially when moving around inside the location perimeters. Also if moving outside the location, when phone wakes up after being inactive, one can get 3-4 notifications about exiting the location, even if the user is far away
-All proper exit notifications (not the fake ones) are displayed twice on iOS
-On Android, some users don't get notifications at all, especially if the app is in background or closed

I am thinking about moving to the acr geofencing plugin (https://github.com/aritchie/geofences/tree/master/), but it is a bit of work. So I am wondering if:

1.Does anyone else have experience with either of these plugins in production?
2.Anyone else have experience with same problems that I am facing?

It's weird that nobody else seems to have problems. I was a newbie to Xamarin when writing the app, I am thinking of creating a small sample. Maybe I have made mistakes, although I have been going through my code several times without finding any. Maybe nobody is actually using the geofence plugin for other than playing around....

Appreciate any insights on this.

Generate/Display Controls Dynamically in Xamarin Forms

$
0
0

Hi Everyone,

I recently started learning Xamarin (MVVM). I am basically trying to convert a traditional Xamrin app to Xamarin Forms (MVVM). I need to remove all the code from code-behind and implement MVVM architecture. I have List objects(some types). I am populating that list using a picker. My task is generate dynamic controls(UI) based on picker selection. For example, if I select type-a in the picker, the stacklayout below the picker should have four entries and 2 switches, if type-b is selected, the stacklayout should display five other controls. In general I need the functionality that generates/displays controls dynamically depending on the type of selection made from picker. I can perform this in code-behind, I add the children to the stacklayout depending on the type selected. Now I need to move this functionality to Forms and get the same done using Xaml.

Can anyone please help me with this?

Thanks a lot in advanced!

Read and receive SMS From Devices

$
0
0

Hi All,

I want to read and receive SMS from my devices using Xamarin.Forms(Android & iOS)

Is there any one have an idea how to I implement?

Please guide me.

How to Sqlite Database import to Xamarin Forms Project

$
0
0

Hi firstly i am so sorry about my english level,

I want to use my already exist sqlite db in my xamarin forms project,
i have a only one table in my db(for test of course). and i want to use this db in xamarin forms project.
i already search on web i try something (like this medium.com/humbledog/how-to-use-sqlite-in-a-xamarin-forms-app-2c6ec5894510 )
but i didn't find and i couldn't
I am new on xamarin forms

Thanks for reading and answers

How to display the Master Page Menu content to be displayed below the navigation bar?

$
0
0

Hi,

I have a minor issue in styling the master-detail page with navigation page in xamarin form.

The content of the master page taking full height of the device. I want the content to be displayed from the bottom of the navigation bar.

Here is the sample of the master page:

<?xml version="1.0" encoding="utf-8" ?>
<MasterDetailPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="XamarinExp.Pages.SampleMasterPage">
  <MasterDetailPage.Master>
    <ContentPage Title="Menu">
      <StackLayout Spacing="0">
        <Label Text="Sample Menu" FontSize="Large" FontAttributes="Bold"></Label>
        <ListView x:Name="lvMenu" SeparatorColor="Green">
          <ListView.ItemTemplate>
            <DataTemplate>
              <ViewCell>
                <StackLayout Padding="10,0,0,0">
                  <Label HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" YAlign="Center" Text="{Binding Title}" TextColor="#03a9f4" >
                    <Label.GestureRecognizers>
                      <TapGestureRecognizer Tapped="OnLabelClicked" />
                    </Label.GestureRecognizers>
                  </Label>
                </StackLayout>
              </ViewCell>
            </DataTemplate>
          </ListView.ItemTemplate>
        </ListView>
      </StackLayout>
    </ContentPage>
  </MasterDetailPage.Master>
</MasterDetailPage>

And this code snippet from the cs file:

NavigationPage nPage = new NavigationPage(new DeviceCheck());
this.Detail = nPage;

And this is what I have in the Droid/Resources/values/styles.xml

<?xml version="1.0" encoding="utf-8" ?>
<resources>

  <style name="MainTheme" parent="MainTheme.Base">
  </style>
  <!-- Base theme applied no matter what API -->
  <style name="MainTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
    <!--If you are using revision 22.1 please use just windowNoTitle. Without android:-->
    <item name="windowNoTitle">true</item>
    <!--We will be using the toolbar so no need to show ActionBar-->
    <item name="windowActionBar">false</item>
    <!-- Set theme colors from http://www.google.com/design/spec/style/color.html#color-color-palette -->
    <!-- colorPrimary is used for the default action bar background -->
    <item name="colorPrimary">#2196F3</item>
    <!-- colorPrimaryDark is used for the status bar -->
    <item name="colorPrimaryDark">#1976D2</item>
    <!-- colorAccent is used as the default value for colorControlActivated
         which is used to tint widgets -->
    <item name="colorAccent">#FF4081</item>
    <!-- You can also set colorControlNormal, colorControlActivated
         colorControlHighlight and colorSwitchThumbNormal. -->
    <item name="windowActionModeOverlay">true</item>

    <item name="android:datePickerDialogTheme">@style/AppCompatDialogStyle</item>

    <item name="android:windowDrawsSystemBarBackgrounds">true</item>
    <item name="android:statusBarColor">@android:color/transparent</item>
  </style>

  <style name="AppCompatDialogStyle" parent="Theme.AppCompat.Light.Dialog">
    <item name="colorAccent">#FF4081</item>
  </style>
</resources>


I want the menu start from below the blue bar.

Any help appreciated. Thanks in advance.


How to make a navigation drawer menu and tab page in xamarin.forms

NullReferenceException in MasterDetailPage custom renderer

$
0
0

I am trying to write a custom renderer for the MasterDetailPage in Xamarin.Forms (v. 2.3.3.175). I need to adjust the default Master width which is way too large compared to its content.

Unfortunately I get a "System.NullReferenceException" as soon as the custom renderer class is created. I have cleaned everything and I still get the error. It seems that simply deriving my class from MasterDetailRenderer is causing the issue.

For the sake of testing I have stripped my custom renderer down to as follows:

[assembly: Xamarin.Forms.ExportRenderer(typeof(ExMasterDetailPage), typeof(ExMasterDetailRenderer))]
namespace MDPageTest.Droid.Renderers {
    public class ExMasterDetailRenderer : MasterDetailRenderer
    { }
}

Nothing else! Still the error occurs. Either commenting the attribute line (hence disabling the custom renderer) or removing the class derivation solves the issue and the app starts without any other error.
Is anybody else experiencing such an issue? Any clue on how to fix it ?

Thank you in advance.
Cheers,
M.

CollectionView included additional space at the bottom

$
0
0

Hi Team,

I am using the CollectionView with Xamarin.Forms (4.1.0.483098-pre1) package. Facing an issue "Extra spacing was added at the bottom of the colletionview when the row-height is set to 'Auto' in its parent grid".

Below is the code I use

    <ContentPage.Content>
        <ScrollView BackgroundColor="Brown">
            <Grid BackgroundColor="Red" RowSpacing="0" Padding="0" ColumnSpacing="0">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"></RowDefinition>
                    <RowDefinition Height="*"></RowDefinition>
                </Grid.RowDefinitions>

                <CollectionView ItemsSource="{Binding Categories}" Grid.Row="0" BackgroundColor="MistyRose">
                    <CollectionView.ItemsLayout>
                        <GridItemsLayout Span="2" Orientation="Vertical"></GridItemsLayout>
                    </CollectionView.ItemsLayout>
                    <CollectionView.ItemTemplate>
                        <DataTemplate>  
                            <StackLayout Orientation="Vertical" BackgroundColor="Yellow" Padding="12">
                                <Image Source="{Binding ImagePath}" Aspect="Fill" WidthRequest="160" HeightRequest="150"></Image>
                                <Label Text="{Binding ImageName}" FontSize="14" FontAttributes="None" TextColor="Black"></Label>
                            </StackLayout>
                        </DataTemplate>
                    </CollectionView.ItemTemplate>
                </CollectionView>

                <Label Text="Home" TextColor="Blue" Grid.Row="1" VerticalOptions="Start" VerticalTextAlignment="Start" BackgroundColor="Green"></Label>

            </Grid>
        </ScrollView>
    </ContentPage.Content>

The grid clearly has 2 rows and there is a space added between the rows without specifying any properties for that spacing. I haven't checked in UWP and iOS. I cannot post the screenshots because of the restriction "You have to be around for a little while longer before you can post links."

How to make custom renders for switch and checkbox?

$
0
0

I need them to look like this.

Tell me where to find more information about custom renders.
To be able to draw borders on elements, remove the checkmark from the checkbox.

Thank you in advance.
Спасибо.

Pinch to zoom an image displayed in a RG Popopup

$
0
0

I am developing a Xamarin app which retrives info from DB, take/choose photo and upload them to remote server, display this images from the remote server and the user can delete them by tap on and press a button.

All the images are put into a ListView, below the XAML struct:

<StackLayout x:Name="stack_display_images">
            <ListView x:Name="list_view_images" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand" RowHeight="150" CachingStrategy="RecycleElement">
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <user:CustomViewCell/>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>
</StackLayout>

The <user:CustomViewCell/> struct:

<StackLayout x:Name="stack_images" BackgroundColor="Transparent">
    <Grid x:Name="grid_images" VerticalOptions="FillAndExpand" HorizontalOptions="CenterAndExpand" Margin="5" >
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
        </Grid.ColumnDefinitions>
    </Grid>
</StackLayout>

In the code behind of CustomViewCell, I create the varius image from URL and add them to the grid, which has 1 column and N rows, N depends by the number of images stored in the remote server (ex: if there are 4 images, the grid will have 4 rows). Every single image has a OnTap method, which open a popup (made by using Rg.Plugins.Popup NuGet package) and make possible to show it bigger than the ListView's preview.

Below the PopUp struct:

<pages:PopupPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:pages="clr-namespace:Rg.Plugins.Popup.Pages;assembly=Rg.Plugins.Popup"
             xmlns:animations="clr-namespace:CEG_inventory.Animations"
             x:Class="CEG_inventory.ShowImage">
    <pages:PopupPage.Animation>
        <animations:UserAnimation/>
    </pages:PopupPage.Animation>
        <StackLayout VerticalOptions="Center" HorizontalOptions="Center">
            <Frame BackgroundColor="Silver">
                <StackLayout Spacing="20">
                    <Image x:Name="custom_image"/>
                    <Button x:Name="button_delete_image" Text="Delete image" Clicked="button_delete_image_Clicked"/>
                    <Button x:Name="button_close_popup" Text="Close" Clicked="OnClose"/>
                </StackLayout>
            </Frame>
        </StackLayout>
</pages:PopupPage>

Everything works like a charm, but I want to zoom on the image such as on Instagram's post (pinch zoom). So there is a way to obtain the same result on xamarin?

Viewing all 77050 articles
Browse latest View live


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