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

List child element is not able to find by using the Appium tool

$
0
0

Hi Folks,

I have worked in the Appium testing tool (Version: 1.15.1), I am testing to Xamarin hybrid app (iOS and Android). I can select the view and also get xpath. But, In the list view, I am not able to select the child elements in the list view and also couldn’t find the xpath for child elements.

We have given automation id in source code. Even Appium inspector is not able to get elements. We used Xamarin.Form 4.3, 4.2, 3.5, and 3.0 versions.

        <ListView.ItemTemplate>
                    <DataTemplate>
                        <ViewCell AutomationId="MyViewCell" AutomationProperties.IsInAccessibleTree="True" >
                            <StackLayout Padding="10" AutomationProperties.IsInAccessibleTree="True" >
                                <Label x:Name="titleLbl" AutomationId="TitleLabel" Text="{Binding Text}" d:Text="{Binding .}" LineBreakMode="NoWrap" Style="{DynamicResource ListItemTextStyle}" FontSize="16" AutomationProperties.IsInAccessibleTree="True" />
                                <Label x:Name="desc" AutomationId="DescLabel" Text="{Binding Description}" d:Text="Item descripton" LineBreakMode="NoWrap" Style="{DynamicResource ListItemDetailTextStyle}" FontSize="13" AutomationProperties.IsInAccessibleTree="True" />
                            </StackLayout>
                        </ViewCell>
                    </DataTemplate>
                </ListView.ItemTemplate>

Kindly give solutions for this problem.

Thanks.


Geolocation - How can I improve the retrieval of coordinates ?

$
0
0

How may I improve on this:

 private static Location loc = null;
 private async void BttLocation_Clicked(object sender, EventArgs e)
        {
            if (loc != null)
            {
                loc = await Geolocation.GetLastKnownLocationAsync();
            }
            else
            {
                var request = new GeolocationRequest(GeolocationAccuracy.Medium);
                loc = await Geolocation.GetLocationAsync(request);
            }

            Map.MoveToMapRegion(MapSpan.FromCenterAndRadius(
                    new Position(loc.Latitude, loc.Longitude), Distance.FromMiles(1)), true);
        }

System.ObjectDisposedException: Cannot access a disposed object. Object name: 'PrimaryToolbarItem'.

$
0
0

Application is crashing after adding the toolbar in master detail page, It is crashing if we come back from the current page and after tapping different page on master and on that page I have added toolbar icons.

{System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'PrimaryToolbarItem'.
at Foundation.NSObject.get_SuperHandle () [0x0004a] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.6.0.12/src/Xamarin.iOS/Foundation/NSObject2.cs:456
at UIKit.UIBarButtonItem.set_Image (UIKit.UIImage value) [0x00033] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.6.0.12/src/Xamarin.iOS/UIBarButtonItem.g.cs:652
at Xamarin.Forms.Platform.iOS.ToolbarItemExtensions+PrimaryToolbarItem.UpdateIconAndStyle () [0x00031] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Extensions\ToolbarItemExtensions.cs:84
at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.b__7_0 (System.Object state) [0x00000] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1021
at Foundation.NSAsyncSynchronizationContextDispatcher.Apply () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.6.0.12/src/Xamarin.iOS/Foundation/NSAction.cs:178
at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.6.0.12/src/Xamarin.iOS/UIKit/UIApplication.cs:86
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0000e] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.6.0.12/src/Xamarin.iOS/UIKit/UIApplication.cs:65
at MotorApp.iOS.Application.Main (System.String[] args) [0x00002] in /Volumes/PMTSL/Ashish/ABC/MotorCatalogApp/ABCApp/MotorApp.iOS/Main.cs:14 }

Hide TabBar on push in Xamarin.Forms

$
0
0

Did anyone manage to implement hiding TabBar on push (iOS)? I found here on forum some examples, but none of them works. I managed to hide TabBar by changing its frame in custom renderer, however ListViews/TableViews have white space in place of TabBar.

Of course I could set Margin="0,0,0,-49", but I'm looking for some generic working solution.

How to handle notification click on Xamarin form ios project

$
0
0

When my Xamarin ios app is in background and I am clicking on the Push notification it is always opening the page i.e in background. Please let me know how I can open another app page on clicking push notifications. when I am clicking on notification public override void DidReceiveRemoteNotification(UIApplication application, NSDictionary userInfo, Action completionHandler)
{
}
event is called but I am not able to redirect to another app page.

"Microsoft.SourceLink.Common.SourceLinkHasSingleProvider" task was not found.

$
0
0

Can any one help me on this am getting this error while build the project.
Error MSB4036 The "Microsoft.SourceLink.Common.SourceLinkHasSingleProvider" task was not found. Check the following: 1.) The name of the task in the project file is the same as the name of the task class. 2.) The task class is "public" and implements the Microsoft.Build.Framework.ITask interface. 3.) The task is correctly declared with in the project file, or in the *.tasks files located in the "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin" directory. MediaManager C:\Users\Path.nuget\packages\microsoft.sourcelink.common\1.0.0-beta2-19367-01\build\InitializeSourceControlInformation.targets.
Please help me. Thanks in advance.

AbsoluteLayout in Stackpanel, Incorrect Height?

$
0
0

When using an AbsoluteLayout in a Stackpanel the height always seems incorrect.

        <StackLayout>
            <AbsoluteLayout x:Name="abLayout">
                <Image x:Name="SpotlightImg"  BackgroundColor="#4F7B63" VerticalOptions="Start"
                       Source="{helper:ImageResource TransPop.Images.bg_placeholder.png}" 
                       AbsoluteLayout.LayoutBounds="0,0,1,1"
                       AbsoluteLayout.LayoutFlags="All"/>
            </AbsoluteLayout>
        <Grid x:Name="hdrGrid" BackgroundColor="Wheat" IsVisible="{OnIdiom Tablet=false, Phone=true}">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="40"/>
                </Grid.RowDefinitions>
                <Label Text="Home" Grid.Column="0" VerticalOptions="Center"  
                        FontAttributes="Bold" HorizontalOptions="CenterAndExpand">
                    <Label.GestureRecognizers>
                        <TapGestureRecognizer  CommandParameter="0"/>
                    </Label.GestureRecognizers>
                </Label>
                <Label Text="Social Media" Grid.Column="1"   
                        VerticalOptions="Center" HorizontalOptions="CenterAndExpand">
                    <Label.GestureRecognizers>
                        <TapGestureRecognizer  CommandParameter="1"/>
                    </Label.GestureRecognizers>
                </Label>
            </Grid>
        </StackLayout>

I expected that my hdrGrid would be directly under the image but instead I get this:

Why is there such a huge gap? Should I not use the stackpanel and absolutelayout in this way?

Image Scanner and Filter


TabbedPage within tabbedpage dosent render correctly on ios

$
0
0

Hi I have tabbedpage within tabbedpage but it dosent render properly on ios
here is a screenshot


XAML

<TabbedPage 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"
        mc:Ignorable="d"
        xmlns:views="clr-namespace:MessagingAppMobile.Views"
        x:Class="MessagingAppMobile.Views.MainPage">
<TabbedPage.Children>
    <NavigationPage Title="Zaloguj">

        <!--<NavigationPage.Icon>
            <OnPlatform x:TypeArguments="FileImageSource">
                <On Platform="iOS" Value="tab_feed.png"/>
            </OnPlatform>
        </NavigationPage.Icon>-->
        <x:Arguments>
            <views:LoginPage />
        </x:Arguments>
    </NavigationPage>
    <TabbedPage  Title="Wiadomości"
                x:Name="MessagesTabbedPage" >
        <TabbedPage.Children>
         <ContentPage Title="Informacje"
                         x:Name="InfoMessagesNavigationPage">
                <!--<ContentPage.Icon>
                    <OnPlatform x:TypeArguments="FileImageSource">
                        <On Platform="iOS" Value="tab_feed.png"/>
                    </OnPlatform>
                </ContentPage.Icon>-->
             <ContentPage.Content>
                 <ListView x:Name="InfoMessagesListView"
                          ItemsSource="{Binding InfoMessages}"
                          CachingStrategy="RecycleElement"
                          ItemSelected="ListView_OnItemSelected">

                     <ListView.ItemTemplate>
                        <DataTemplate>
                            <ViewCell>
                                <StackLayout >
                                    <Label
                                        Text="{Binding Subject}"></Label>
                                </StackLayout>
                            </ViewCell>
                        </DataTemplate>
                    </ListView.ItemTemplate>
                </ListView>
                </ContentPage.Content>
         </ContentPage>
            <ContentPage Title="Intencje">
             <!--<ContentPage.Icon>
                 <OnPlatform x:TypeArguments="FileImageSource">
                     <On Platform="iOS" Value="tab_feed.png"/>
                 </OnPlatform>
             </ContentPage.Icon>-->
                <ContentPage.Content>
                 <ListView x:Name="PreyersMessagesListView"
                           ItemsSource="{Binding PreyerMessages}"
                           CachingStrategy="RecycleElement"
                           ItemSelected="ListView_OnItemSelected">
                     <d:ListView.ItemsSource>
                         <x:Array Type="{x:Type x:String}">
                             <x:String>Item 1</x:String>
                             <x:String>Item 2</x:String>
                             <x:String>Item 3</x:String>
                             <x:String>Item 4</x:String>
                             <x:String>Item 5</x:String>
                         </x:Array>
                     </d:ListView.ItemsSource>
                     <!--Built in Cells-->
                     <ListView.ItemTemplate>
                         <DataTemplate>
                             <ViewCell>
                                 <StackLayout>
                                     <Label
                                         Text="{Binding Subject}"></Label>
                                 </StackLayout>
                             </ViewCell>
                         </DataTemplate>
                     </ListView.ItemTemplate>
                 </ListView>
             </ContentPage.Content>
            </ContentPage>
         <ContentPage Title="Inne">
                <!--<ContentPage.Icon>
                    <OnPlatform x:TypeArguments="FileImageSource">
                        <On Platform="iOS" Value="tab_feed.png"/>
                    </OnPlatform>
                </ContentPage.Icon>-->
             <ContentPage.Content>
                 <ListView x:Name="OtherMessagesListView"
                           ItemsSource="{Binding OtherMessages}"
                           CachingStrategy="RecycleElement"
                           ItemSelected="ListView_OnItemSelected">
                     <d:ListView.ItemsSource>
                         <x:Array Type="{x:Type x:String}">
                             <x:String>Item 1</x:String>
                             <x:String>Item 2</x:String>
                             <x:String>Item 3</x:String>
                             <x:String>Item 4</x:String>
                             <x:String>Item 5</x:String>
                         </x:Array>
                     </d:ListView.ItemsSource>
                     <!--Built in Cells-->
                     <ListView.ItemTemplate>
                         <DataTemplate>
                             <ViewCell>
                                 <StackLayout>
                                     <Label
                                         Text="{Binding Subject}"></Label>
                                 </StackLayout>
                             </ViewCell>
                         </DataTemplate>
                     </ListView.ItemTemplate>
                 </ListView>
             </ContentPage.Content>
            </ContentPage>
     </TabbedPage.Children>
    </TabbedPage>
    <NavigationPage Title="Nowa">
        <x:Arguments>
            <views:SendMessagePage/>
        </x:Arguments>
    </NavigationPage>
</TabbedPage.Children>
</TabbedPage>

I looked all over but couldn't find anything helpfull
any ideas?

After upgrading OnePlus6 Android phone to Android 10 I can no longer deploy my app to device

$
0
0

I have a Xamarin Forms app compiled using Visual Studio 16.4 Xamarin Forms 4.3.
After upgrading my phone to Android 10 I no longer can deploy my app for debugging.
I get the following error trying to debug using the device:

Severity Code Description Project File Line Suppression State
Error ADB1000: Deployment failed
Mono.AndroidTools.RequiresUninstallException: The installed package is incompatible. Please manually uninstall and try again.
at Mono.AndroidTools.Internal.AdbOutputParsing.CheckInstallSuccess(String output, String packageName) in E:\A_work\222\s\External\androidtools\Mono.AndroidTools\Internal\AdbOutputParsing.cs:line 339

Any ideas?

Tabbar constantly throws the item in the browser !

$
0
0

Hi everyone !

The tabbar menu of my application I developed with Xamarin forms is as follows ;

When the user presses the tabbar item that I marked, he goes to the website with the browser. This works properly. However, when the user returns to the application after going to the browser, he throws again the user back into the browser. After returning to the application, the user goes back to the browser without having the opportunity to switch to other tabs.

in .cs ;

I don't have this problem on my iOS platform. Only on Android.

How can i solved ?

Thanks in advance !

how to customize user impressions and expand views

$
0
0

i want to make a photo feed where its nothing but photos no text or buttons. and a user could scroll through but if a user slows scrolling and there finger is touching one picture for say .25s it will expand to a full post username and likes/desc and if comments are clicked expand twice. so how would i customize user impressions like so so even if there scrolling or staying still if they are touching it for x amount of time the post expands and have 3 different states.

Image As Background

$
0
0

Hello,

I am working with Xamarin Forms and would like to use an image as the background for some pages. I have several Views and Layouts on different pages, and would like to overlay them onto a background image, selecting the image based on the page. I found how to use a solid color for the background, by setting the BackgroundColor on various components (like the primary StackLayout I have on a given page), but is it possible to use an image instead of a solid color? If so, could you include an example (short, quick, and dirty is perfectly fine). If not, does an alternative solution exist, perhaps using Renderers? I am targeting Android and iOS currently, if that helps at all.

Thank you.

System.DllNotFoundException: '__Internal assembly: type:

$
0
0

Hi,

Why I am getting this error with brand new project when running on Android emulator or device.

Attached is the build output

Thanks,
Jassim

Hiding empty UITableView section header

$
0
0

Hi,

I want to hide empty UITableView section header, is this possible?


CarouselPage with ContentPages in ItemTemplate doesn't support UseSafeArea

$
0
0

I have a CarouselPage in my app where the items are visualized as ContentPages. I noticed that with this setup UseSafeArea doesn't work. Each ContentPage always covers the full display area on a device that should have insets. I tried the following to solve this:

First I tried to force the setting of safe area myself in OnAppearing(), with:

if (Device.RuntimePlatform == Device.iOS)
{
  On<Xamarin.Forms.PlatformConfiguration.iOS>().SetUseSafeArea(true);
}

That doesn't work.

I then checked what the framework actually reports as insets with:

if (Device.RuntimePlatform == Device.iOS)
{
  On<Xamarin.Forms.PlatformConfiguration.iOS>().SetUseSafeArea(true);
  var safeInsets = On<Xamarin.Forms.PlatformConfiguration.iOS>().SafeAreaInsets();
  this.Padding = safeInsets;
}

On devices that need insets (iPhone XR, iPad Pro, etc.) the insets are all 0.

I then tried to define UseSafeArea in the ContentPage's ItemTemplate, like so:

<CarouselPage.ItemTemplate>
    <DataTemplate>
      <ContentPage ios:UseSafeArea="True">
         ...
      </ContentPage>
    </DataTemplate>
</CarouselPage.ItemTemplate>

That didn't work either.

I finally managed to get it working by forcing the insets in code behind of my CarouselPage with an own implementation of a dependency service for safe area insets and setting the ContentPage's padding each time the current page in CarouselPage changes. It look as follows:

    public partial class ArticleXFCarouselPage : CarouselPage
    {
        ArticleCarouselViewModel _carouselVM;
        bool _isInitializing;

        public ArticleXFCarouselPage (ArticleCarouselViewModel vm)
        {
            _carouselVM = vm;
            this.BindingContext = vm;
            _isInitializing = true;
            ItemsSource = _carouselVM.Items;
            CurrentPage = Children[_carouselVM.CurrentItemIdx];
            InitializeComponent();
            _isInitializing = false;
        }

        double _width;
        double _height;
        Thickness _contentPagePadding = new Thickness();

        protected override void OnSizeAllocated(double width, double height)
        {
            base.OnSizeAllocated(width, height);
            if (Equals(_width, width) &&
                Equals(_height, height))
                return;

            var oldWidth = _width;
            _width = width;
            _height = height;

            // Has the device been rotated ?
            if (width != -1 && !Equals(width, oldWidth))
            {
                SetSafeArea(width < height ? PageOrientation.Vertical : PageOrientation.Horizontal);
            }
        }

        void SetSafeArea(PageOrientation orientation)
        {
            if (Device.RuntimePlatform == Device.iOS)
            {
                _contentPagePadding = DependencyService.Get<IPlatformService>().GetSafeAreaInset();
                if (orientation == PageOrientation.Vertical)
                {
                    _contentPagePadding.Top = 0;
                }
                CurrentPage.Padding = _contentPagePadding;
            }
        }

        protected override void OnCurrentPageChanged()
        {
            base.OnCurrentPageChanged();
            if (!_isInitializing)
            {
                CurrentPage.Padding = _contentPagePadding;
                // Tell viewmodel to load additional articles if any
                Device.BeginInvokeOnMainThread(async () =>
                {
                    var idx = Children.IndexOf(CurrentPage);
                    await _carouselVM.OnArticleBecomesVisibleAsync(idx);
                });
            }
        }
    }

The dependency service for iOS looks as follows:

    public class PlatformService : IPlatformService
    {
        public PlatformService()
        { }

        public Thickness GetSafeAreaInset()
        {
            var inset = new Thickness();
            if (UIApplication.SharedApplication.KeyWindow != null)
            {
                if (UIDevice.CurrentDevice.CheckSystemVersion(11, 0))
                {
                    var safeAreaInsets = UIApplication.SharedApplication.KeyWindow.SafeAreaInsets;
                    inset.Top = safeAreaInsets.Top;
                    inset.Bottom = safeAreaInsets.Bottom;
                    inset.Left = safeAreaInsets.Left;
                    inset.Right = safeAreaInsets.Right;
                }
            }
            return inset;
        }
    }

That of course leaves me with the question: Did I overlooked something? Is there indeed an error in CarouselPage and if so are there plans to solve this?

Hiding empty UITableView section header

$
0
0

Hi,

I want to hide empty UITableView section header, is this possible?

Prompt user to change battery optimization settings - Android

$
0
0

Hi,
I am looking for some solution for disabling battery optimization setting for my application.
When user install app first time and Battery optimization is enable, App should prompt custom popup (Popup text based on user language), and after clicking on button, It should navigate to setting page, there user can disable battery optimization.
Same setting app should save, And should not ask again and again.

App crashes on page disappearing, we have used Rox.Xamarin.Video plugin to play the video.

$
0
0

In app we have a page where video is displayed using the "Rox.Xamarin.Video" plugin, but issue is when user navigate back from the page it crashes the app. We have also surrounded the code with try catch block.
as below:

protected override void OnDisappearing()
{
try
{
VideoPlayer.Stop();
VideoPlayer = null;
}
catch (Exception ex)
{

        }

}

Please help us it is crashing in the production but we are not able to reproduce it.

Unable to use Plugin.CloudFirestore

$
0
0

I am using xamarin froms to develop an uber like application. i am using the code from ducumentation to get cdocument.
var document = await CrossCloudFirestore.Current .Instance .GetCollection(Constants.FIREBASE_COLLECTION_USER) .GetDocument(UID) .GetDocumentAsync();

whenever debugger tries to cross this code, nothing happens and the control is lost forever. i am unable to get the data and also unable to touch firestore databse. Please help to resolve.

Viewing all 77050 articles
Browse latest View live


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