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

How to arrange native code items when using binding assemblies which project to embed them into

$
0
0

I’ve been working on integrating a vendor’s SDK “ThirdParty” into my Xamarin Forms app “MyApp”. I ran into something with jar/aar binding that I figured out a hack for, but it seems like there should be a better way.

Intended Xamarin code structure - 6 assemblies as follows:

Code Project - Description

(1) MyApp - Cross Platform core code

References: (4)

(2) MyApp.IOS - IOS App

References: (4) (6)

(3) MyApp.Android - Android App

References: (4) (5)

Here, I hope not to have to include in this high-level project: - libThirdPartyClient.so as AndroidNativeLibrary and - ThirdPartyclient.jar as AndroidJavaLibrary

(4) ThirdPartyConnector - Cross-Platform ThirdParty sub-project

References: Nothing from 1-6

Where I will house common code and abstractions of things located down in projects (5) and (6), which are to be used by project (1).

(5) ThirdPartyConnector.Android - Binding Assembly

References: (4)

Contains implementations of abstractions from (4).

Here, I Expect to include in this project: - libThirdPartyClient.so as AndroidNativeLibrary and - ThirdPartyclient.jar as AndroidJavaLibrary

(6) ThirdPartyConnector.IOS - Binding Assembly

References: (4)

Contains implementations of abstractions from (4).

What I run into at runtime is that unless I include the libThirdPartyClient.so and ThirdPartyclient.jar files inside assembly (3) MyApp.Android (I had originally included them in (5) ThirdPartyConnector.Android), the so and jar files do not get included into the final APK file. At runtime, then the app runs into JNI Java Class Not Found errors because the so and jar file content isn’t present/included in the built APK file.

What I really don’t like about it is that no code in assembly (3) has any direct calls into these subordinate java artifacts that are needed at a much lower level (5) in the solution at runtime. My project (3) is big enough on its own – hence my motivation to break things down into logical sub-projects.

Questions:

1.Does anyone have any suggestions on how these assemblies can better linked/embeded native items whem you have separate projects like (3) and (5)?

2.If one had, for example 4 more jars from other vendors/packages, would one have to also include all of these jar and aar files in my assembly (3) project? Seems messy, but doable if one really has to.

3.This post has been focused on Android, but do you have to do similar things for IOS, when it comes to embedding native code? Will I have to embed code used by project (6) into project (2)?

Any tips, pointers, or insight into how this works at compile-time will be greatly appreciated.


Child rendering behaviour mismatched after upgrading Xamarin.Forms (>4.0) in FlexLayout

$
0
0

Hi All,

I have a simple sample with the layout structure of FlexLayout which has more number of Grid. Each Grid has two children that are

  1. Grid with Label as a child
  2. Custom View (TouchView) which is inherited from View.

    <FlexLayout HorizontalOptions="Start" 
                                    VerticalOptions="Center" 
                                    Direction="Row" 
                                    Wrap="Wrap" 
                                    BindableLayout.ItemsSource="{Binding ChildItems}"
                                    JustifyContent="Start" 
                                    AlignContent="Start" 
                                    AlignItems="Start">
    
                <FlexLayout.BindableLayout.ItemTemplate>
                    <DataTemplate>
                        <Grid>
                            <Grid BackgroundColor="Aqua">
                                <Label TextColor="Black" Text="{Binding}"/>
                            </Grid>
                            <local:TouchView/>
                        </Grid>
                    </DataTemplate>
                </FlexLayout.BindableLayout.ItemTemplate>
    
            </FlexLayout>
    

Here TouchView represents like

public class TouchView:View
    {

    }

This FlexLayout wrap its child element correctly up to the Xamarin.Forms version of 3.6.0.539721

But after 4.0.0.425677 , it rendered be like in below

Note : Issue only with Android platform.

@Xamariners please check this and update us with possible solution. Actually it blocks our development cycle. Taking this a high priority and provide a solution ASAP.

I have attached the sample in both lower and higher version of Xamarin.Forms.

Regards,
Hemalatha M.

CollectionView not firing SelectionChangedCommand

$
0
0

I am using FreshMVVM to bind my view models to my views, and all commanding has worked great so far. However, I am not able to get the SelectionChangedCommand to fire when I change the selection of a CollectionView.

Full source code can be found here

Here is my XAML...

<StackLayout>
    <CollectionView SelectionMode="Single"
                    ItemsSource="{Binding Tags}"
                    SelectedItem="{Binding SelectedTag, Mode=TwoWay}"
                    SelectionChangedCommand="{Binding SelectedTagChangedCommand}">
        <CollectionView.ItemTemplate>
            <DataTemplate>
                <StackLayout>
                    <Label Text="{Binding .}" />
                </StackLayout>
            </DataTemplate>
        </CollectionView.ItemTemplate>
    </CollectionView>
</StackLayout>

And the page model...

public class MainPageModel : FreshBasePageModel
{
    public override void Init(object initData)
    {
        Tags = new ObservableCollection<string>() { "A", "B", "C" };
        SelectedTag = "B";

        base.Init(initData);
    }

    public ObservableCollection<string> Tags { get; set; }

    public string SelectedTag { get; set; }

    public Command SelectedTagChangedCommand
    {
        get
        {
            return new Command(() =>
            {
                   // ****** 
                   // ****** this is never called
                   // ****** 
            });
        }
    }
}

Can anyone see the issue here?

Transparent Color not working with ViewCellRenderer

$
0
0

Hi,
I have one Problem.
I created new ViewCellRenderer for Android.
If I put color "Transparent", SelectedItem gets Orange Color.
Other colors work without problems.
Does anyone have any solution ?
I'm testing on Android.

Thanks !

How to implement splitview in already created xamarin project ?

$
0
0

I have one Xamarin Application, while developing we only focused on look and feel for iphone. Now we want to implement SplitView for some page in our application.

But it is giving run time error :

System.InvalidOperationException: Title property must be set on Master page

I already set title as given in link inside searchTabletpage.cs file.

public SearchTabletPage()
        {
            Title = "Details";
            this.MasterBehavior = MasterBehavior.Default;

            Master = new SearchPage(true);
            Detail = new ContentPage()
            {
                Content = new StackLayout
                {
                    VerticalOptions = LayoutOptions.Center,
                    HorizontalOptions = LayoutOptions.Center,

                    Children = {
                        new Label { Text = "Select a Record", FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)) }
                    }

                }

            };

            ((SearchPage)Master).ItemSelected = (searchDetail) =>
            {

                BusinessDetailPage businessDetail = new BusinessDetailPage(searchDetail.InfogroupId,searchDetail.Distance,searchDetail.FullAddress,searchDetail.Phone);
                Detail = businessDetail;
                if (Device.RuntimePlatform != Device.UWP)
                {
                    IsPresented = false;
                }
            };

            IsPresented = true;
        }
    }

I have followed steps given in blog: Bringing Xamarin.Forms Apps to Tablets

Please help.
Thanks in Advance.

Is XamlCompile broken in latest Forms/VS??

$
0
0

Just so happens that today is first time trying out the XamlC feature. At first I tried the assembly level attribute in my App.cs file:

[assembly: XamlCompilation(XamlCompilationOptions.Compile)]

After compiling, I was getting a bunch of errors that were all identical. I also got a a different error on any page using a TemplateControl. So I pulled it off the assembly level and put a single class-level attribute on one page, and it still failed with the same error:

Value cannot be null.
Parameter name: method  

I poked around on Stackoverflow and found that about a year ago someone had the same issue (here), but they said they resolved it by upgrading Xam Forms to latest version. Since I'm on the latest stable versions, I have no where to go there.

I tried this class-level attribute on several pages in my app and only found it to work on a single page in my entire app... just so happens this page has zero bindings in the XAML markup. I'm wondering if a bug was introduced that causes it to blow up.

Markup of page that doesn't work:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="Prepify.App.Pages.MainMenu"
                         xmlns:controls="clr-namespace:ImageCircle.Forms.Plugin.Abstractions;assembly=ImageCircle.Forms.Plugin.Abstractions"
                         BackgroundColor="White"
             Title="Menu">
    <StackLayout VerticalOptions="FillAndExpand">
        <ListView
            Header="{Binding .}"
            SeparatorColor="{StaticResource dividerColor}"
            HasUnevenRows="True"
            ItemSelected="AppMenu_OnItemSelected"
            ItemTapped="AppMenu_OnItemTapped"
            ItemsSource="{Binding Items}"
            x:Name="appMenu">

            <ListView.HeaderTemplate>
                <DataTemplate>
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="10"/>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="30"/>
                            <ColumnDefinition Width="10"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="30"/>
                            <RowDefinition Height="80"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="5"/>
                        </Grid.RowDefinitions>

                        <BoxView Grid.ColumnSpan="4" Grid.RowSpan="4" BackgroundColor="{StaticResource grayDark}"/>
                        <controls:CircleImage Grid.Column="1" Grid.Row="1" HorizontalOptions="Start" VerticalOptions="End" Source="{Binding ProfileImageUrl}" WidthRequest="75" HeightRequest="75"/>
                        <Label Grid.Column="1" Grid.Row="2" Text="{Binding FullName}"/>
                        <ActivityIndicator Grid.Column="2" Grid.Row="2" IsVisible="{Binding IsBusy}" IsRunning="{Binding IsBusy}" Color="White" WidthRequest="20" HeightRequest="20" VerticalOptions="Center" />

                    </Grid>
                </DataTemplate>
            </ListView.HeaderTemplate>
            <ListView.ItemTemplate>
                <DataTemplate>
                    <ViewCell>
                        <StackLayout Orientation="Horizontal" >
                            <StackLayout.Padding>
                                <OnPlatform x:TypeArguments="Thickness" Android="15,15,15,15" iOS="25,12,15,12" />
                            </StackLayout.Padding>
                            <Image Source="{Binding Icon}" VerticalOptions="Center" WidthRequest="20" HeightRequest="20"/>
                            <Image WidthRequest="20"/>
                            <Label Text="{Binding Label}" VerticalOptions="Center" TextColor="{Binding LabelColor}" Style="{DynamicResource ListItemTextStyle}"/>
                        </StackLayout>
                    </ViewCell>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>
    </StackLayout>
</ContentPage>

Markup of only page that does work:

<?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="Prepify.App.Pages.Root"
    xmlns:pages="clr-namespace:Prepify.App.Pages;assembly=Prepify.App"
    MasterBehavior="Popover"
    Title="Make Preparedness Easy">

    <MasterDetailPage.Master>
        <pages:MainMenu/>
    </MasterDetailPage.Master>

</MasterDetailPage>

I'm using
Visual Studio 2015
Xamarin.Forms 2.3.3.193
Xamarin.VS 4.3.0.784

Xamarin Forms Bluetooth Classic--Emergency!!

$
0
0

I am trying to write an app about listing the bluetooth device and connect with them with xamarin forms. I found a code from internet but it is for BLE and looks good, however, my target device is RN-42 which is a classic bluetooth device and of course I can't detect the device with my iPhone.

So Anyone know have to let the iOS app detect the RN-42 classic bluetooth?

Please give the specific steps about how to solve this problem, I have no experience about Bluetooth iOS app development.

i am in a hurry please help me, thanks!

Xamarin Forms - Shell Flyout without items?

$
0
0

Hi, I want to use "shell", but I'm trying to make the shell flyout content without items, I want to build my own content on that section, it there a way for do it?

I don't want to use the 1 picture + title.

I mean the middle part on this picture:


Receiving the data from the BLE device and draw on the iOS App

$
0
0

Hi I am planning to design an app that connect with a ble device and receive the x, y value from the device, then display the location based on the values of device on the picture coordinate.

So far I solved the connection part and have no idea how to get the values from the device and use them to draw the point, anyone can give me a clear example?

Various warnings when compiling Xamarin Forms solution from Android project.

$
0
0

Hi,

I'm getting various warning when compiling my Xamarin Forms solution but they all seem to be coming from the Android project and I've got no idea on how to resolve them. All together I've got 10 warnings but here are a few of the warnings which will hopefully help:

========================
Drawable.avd_hide_password_x warnings

Warning Skipping MyApp.Mobile.Droid.Resource.Drawable.avd_hide_password_1. Please check that your Nuget Package versions are compatible. MyApp.Mobile.Android

Warning Skipping MyApp.Mobile.Droid.Resource.Drawable.avd_hide_password_3. Please check that your Nuget Package versions are compatible. MyApp.Mobile.Android

Other warnings

Warning Skipping MyApp.Mobile.Droid.Resource.Id.design_menu_item_action_area. Please check that your Nuget Package versions are compatible. MyApp.Mobile.Android

Warning Skipping MyApp.Mobile.Droid.Resource.Id.fixed. Please check that your Nuget Package versions are compatible. MyApp.Mobile.Android

========================

I've googled it and found a couple of suggestion.

  1. Xamarin.Forms library may be out of date: I checked and it was. I've updated it since and it is now the very latest version but to no avail.

  2. Set the version of the Android project to 8. I created a new virtual device yesterday and when I did I had set it to Oreo 8.1 - API 27. When I checked the version, it was actually set to Pie 9.0 - I changed it to 8.1 but again, no luck

  3. Check Nuget packages packages are compatible. I've checked all the ones from the Android project and they are all from MonoAndroid 6 or higher all the way to 8.1 which I assume should be ok.

Any ideas on how I can remove these??

Thanks.

Thierry

Masked Image

$
0
0

Hi guys ... a simple question : Could we have a masked image in xamarin forms ?? is it possible ?? in another word ... could we show an image inside an irregular shape ?

Change Tabbed Page From Button

$
0
0

Hello,

I was currently working with Tabbed Page :

<?xml version="1.0" encoding="utf-8" ?>
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:me="clr-namespace:Let_s_go_out.Views.Pages;assembly=Let_s_go_out"
             x:Class="Let_s_go_out.Views.MainPage"
             >
  <TabbedPage.Children >
    <me:PlacesList />

    <me:PlaceSearch />


  </TabbedPage.Children>
</TabbedPage>

And in the PlaceSearch content I have a button :

<StackLayout Grid.Row="9" Orientation="Horizontal" > <Button Text="Rechercher" HorizontalOptions="Center" VerticalOptions="Center" Command="{Binding Search}"></Button> </StackLayout>

So my question is : How I can go on the "PlaceList" Tabbed page when the Button is clicked ?

Thanks :)

Universal Links not working in my Xamarin.Forms iOS app

$
0
0

I followed these instructions, but I can't get my app to respond when clicking on specific web links.

https://xamarinhelp.com/ios-universal-links/

Here is my apple-app-site-association file. It has no extension. The file downloads when I access it with Google Chrome using a link like this. https://portal.mydomain.com/.well-known/apple-app-site-association

{
   "applinks": {
     "apps": [],
     "details": [
       {
         "appID": "MYAPPID.com.mydomain.appname",
         "paths": [ "/PublicOffers/OffersPage" ]
       }
     ]
   }
}

Here are my applink settings.

applinks: portal.mydomain.com

Here are URL examples.

https://portal.mydomain.com/PublicOffers/OffersPage?id=SOMEGUID&cid=SOMEGUID

https://portal.mydomain.com/PublicOffers/OffersPage/SOMEGUID

When in Debug mode, I've noticed that ContinueUserActivity and OpenUrl never get called.

Here is my current development environment. I'm in the process of configuring a newer MacBook Pro, but at this time I'm connecting to an older MacBook running XCode 8.2.1 (can't go any higher).

Microsoft Visual Studio Enterprise 2015
Version 14.0.25422.01 Update 3
Microsoft .NET Framework
Version 4.7.02556

Installed Version: Enterprise

Xamarin 4.3.0.789 (4d2ed3d)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.iOS 10.4.0.128 (ba11e48)
Visual Studio extension to enable development for Xamarin.iOS.

Any ideas why this is not working? Thanks!

How to block the resizing of the application view in uwp?

$
0
0

Hello, is it possible to prevent the user in UWP from being able to modify the size of the window? Is there a way to configure a minimum size of the application view or otherwise, is it possible to configure that the UWP application is always in full screen? thank you.

draw a dot on image

$
0
0

Does any one know how to add a dot on an image?

In xml file, I use to display a image, now I want to add a dot on this image by giving a x, y value and directly draw a dot at the location I want.

Anyone know how to achieve this?


Rare behavior of the stack layout

$
0
0

Hi, i'm using SfDataform plugin, from h ttps ://www.syncfusion.co m .
when I launch the application, the layout gives error, but when I upload an image, it is fixed, could anyone know what is happening?

Video Error: http s://youtu.be/ gXgzqnWh39A (i can't post links, so please, put together) hoping this video helps to clear up the problem

Code:

<ContentPage.BindingContext>
    <local:CrearEventoVM/>

</ContentPage.BindingContext>

<ContentPage.Resources>
    <local1:GooglePlaceVM x:Key="googleplace"/>

    <ResourceDictionary>
        <DataTemplate x:Key="itemTemplate">
            <StackLayout Orientation="Horizontal">

                <Label Text="{Binding Address}" TextColor="Black" LineBreakMode="TailTruncation"/>
            </StackLayout>
        </DataTemplate>
    </ResourceDictionary>
</ContentPage.Resources>


<ContentPage.Content>


    <ScrollView>
        <StackLayout>



            <Grid IsVisible="{Binding ImageVisible}">
                <Grid.RowDefinitions>
                    <RowDefinition Height="100" />

                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="8*" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>

                <Image   
                         Grid.Row="0"  Grid.Column="0"  Grid.ColumnSpan="2"
                        VerticalOptions="Fill" 
                        x:Name="image" 
                     Aspect="AspectFill"
                        BackgroundColor="Gray" IsVisible="{Binding ImageVisible}">
                    <Image.GestureRecognizers>
                        <TapGestureRecognizer Tapped="Button_TouchImage" Command="{Binding TouchImageCommand, Mode=TwoWay}">

                        </TapGestureRecognizer>
                    </Image.GestureRecognizers>
                </Image>

                <Label 
                             Grid.Row="0" Grid.Column="1"
                               TextColor="Black" 
                               Text="X" 
                               FontSize="30"   
                               HorizontalTextAlignment="Center" HorizontalOptions="End"
                           IsVisible="{Binding DeleteImageVisible, Mode=TwoWay}">
                    <Label.GestureRecognizers>
                        <TapGestureRecognizer   Tapped="Button_DeleteImage" Command="{Binding DeleteImageCommand}">

                        </TapGestureRecognizer>
                    </Label.GestureRecognizers>
                </Label>

            </Grid>

            <BoxView Color="Gray" Grid.Row="0"  VerticalOptions="Fill" IsVisible="{Binding BoxViewVisible, Mode=TwoWay}">
                        <BoxView.GestureRecognizers>
                            <TapGestureRecognizer Tapped="Button_TouchImage" Command="{Binding TouchImageCommand}">

                            </TapGestureRecognizer>
                        </BoxView.GestureRecognizers>
                    </BoxView>


            <Entry x:Name="asd" ></Entry>
            <autocomplete:SfAutoComplete VerticalOptions="Fill" x:Name="autoComplete" 
                                      BindingContext="{Binding Source={StaticResource googleplace}}"
                                     DropDownItemHeight="35" 
                                     HeightRequest="50" 
                                     LoadMoreText="Ver Más."
                                     MaximumSuggestion="4" 

                                     HighlightedTextColor="Red"
                                     ClearButtonColor="Red"

                                      DisplayMemberPath="Address"
                                     ImageMemberPath="ImageIcon"

                                   SuggestionBoxPlacement="Bottom"

                                ItemTemplate="{StaticResource itemTemplate}" 
                                    SelectionChanged="Selection_Changed"
                                MultiSelectMode="Token"
                                FocusChanged="AutoComplete_FocusChanged"
                                 SuggestionMode="Custom"
                                     ValueChanged="AutoComplete_TextChanged"

                                    Watermark="Busque por curso, grupo o persona."
                                     NoResultsFoundText="Sin Resultados"
                                    Text="{Binding AddressText}" 
                                      DataSource="{Binding Addresses, Mode=TwoWay}">



            </autocomplete:SfAutoComplete>





            <dataForm:SfDataForm x:Name="dataForm" LabelPosition="Top"
                     DataObject="{Binding ContactsInfo}" VerticalOptions="FillAndExpand"/>





            <Button  VerticalOptions="End" Clicked="Button_Guardar_Todo" Text="Guardar"/>




        </StackLayout>
    </ScrollView>
</ContentPage.Content>

~~~~
Sorry for my bad english

How to resolve errors in Resource.designer.cs when building for Android

$
0
0

My Android build has been reporting errors in Resource.designer.cs, an automatically generated file. The errors result from a full-stop (aka period) being in a couple of entries in the .cs file, as per the image below.

If I look in G:\tfs\myapp\myapp\AndroidForForms\AndroidForForms.Android\Resources\Resource.designer.cs
I see:

            // aapt resource value: 0x7f0b008c
            public const int bottomtab_navarea = 2131427468;

            // aapt resource value: 0x7f0b008d
            public const int bottomtab_tabbar = 2131427469;

But if I look in G:\tfs\myapp\myapp\AndroidForForms\AndroidForForms.Android\obj\Debug\81\designtime\Resource.designer.cs
I see the erroneous

            // aapt resource value: 0x7F030180
            public const int bottomtab.navarea = 2130903424;

            // aapt resource value: 0x7F030181
            public const int bottomtab.tabbar = 2130903425;

Any idea what might be causing this, and how I can fix it? (it was happening before I changed my PCLs to .Net Standard 2, and is still happening afterwards)

Can we create a custom callout like grid in xamrin.forms. Please provide me an example Ask

$
0
0

The map callout should appear as a grid which shows the all the attributes of feature tabbed in web map view and we can edit the features too.

How to hide a stack layout when scrolling up in the listview?

Proper format for date

$
0
0
Hi xamarin forum,

I try to follow the instructions for format for date but I am getting error here is my code

Label Text="{Binding Date, StringFormat='{0:MMMM dd, yyyy}'}">

because I tried it and it has blue lines below 0, dd and yyyy
Viewing all 81910 articles
Browse latest View live


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