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

PushModalAsync() new window is hidden under previous window

$
0
0

Xamarin forms on Android.

I'm using PushModalAsync() to open a new window. Most of the time it works fine, but occasionally the new window is created but is not visible, as if it's hidden behind the previous page. The OnAppearing() event for the new page is triggered. If I tap the menu button on my tablet to bring up the list of open applications, then tap on my application to return focus to my app, then suddenly the new window pops into view. Is there a way to force the new window to pop to the top, or force a screen redraw of some kind after PushModalAsync()? This is how I'm opening the new window:

public void OpenMyNewWindow(void)
{
  try
  {
    if (myNewPage == null)
      myNewPage = new MyNewPageType();
    Navigation.PushModalAsync(myNewPage);
  }
  catch (Exception e)
  {
    // handle errors... 
  }
} 

How to enable log option in android and ios devices using xamarin.forms app

$
0
0

In my cross-platform Xamarin Forms application I would like to have a Logging option. If it's enabled, it should generate a log file stating the errors or in which step the app is crashing (if any of these takes places while the app is running) and I should be able to pull and check this generated log file.

When I googled for this I found on many sites that we need to debug using usb and check it on android adb, but once the application goes live and user downloads it in their phone if app crashes any time then the user should be able to turn on the logging button and once the process is run it generates a log file. The user can then send the file to the developer to check what exactly is happening in the system.

How do I implement this feature in Xamarin Forms for both iPhone and Android?

Unable to display the downloaded PDF in webview

$
0
0

I am facing issue in displaying the downloaded pdf in webview of xamarin android

code i am using for getting the path for downloading
public string GetLocalFilePath(string filename)
{
// string path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData);
var documentsPath = Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryDownloads);
string filepath= Path.Combine(documentsPath.Path, filename);
return filepath;
}

usimg dependency injection for tracking the path

var data = App.Locator.DependencyService.Get().GetLocalFilePath("Hello.pdf");

File Operation to get the file
FileInfo filepath = new FileInfo(data);
var filestorage = filepath.Directory.GetFiles();

Binding the path to webview in xaml(pcl)

var data = App.Locator.DependencyService.Get().GetLocalFilePath("Hello.pdf");
webview.Source=data;

i am unable to display pdf in webview for xamarin android,help me with this issue

WebView on Xamarin.Forms is not loading the files from the application local storage

$
0
0

Hi,
I am developing a application on using Xamarin.forms for the cross platforms (UWP,iOS and Android). I am able to download the file from server and able to store to local storage using PCLStorage cross platform plugin.

I am trying to create a viewer using the WebVIew which will display the local storage files as per each platform support.

I am using WebView to create the viewer so that this can be used on each platform. When loading the files from local storage webview is not loading the files even not showing any error in loading. I am facing this issue on the UWP platform.

I am following the URL schema ms-appdata:///local/ for loading the local storage files as per

E.g:_
ms-appdata:///local/Packages/8126d6e9-f697-4abd-924b-73a159412c15_4fh6xh3q1xw62/roaming/1-17045247-1.PDF

Please help me to resolve this issue.

Thanks & Regards,
Alok Pandey

Text in grouped Listview Slides out of grid when scrolling for sometime before adjusting back

$
0
0

Am showing a list of fuel prices and fuel types grouped on based on fuel stations. However, when I scroll the list, the label at the start slides out of the row for a moment and only comes back to original position if the page is left by without any interaction for some time.
The behavior is completely random meaning some labels might shift one time and some other at another. Also, this only happens with the first label inside the ListView ItemTemplate.

Attaching screenshot for better clarity.

below is the code for the listView

<ListView ItemsSource="{Binding ListOfFuel}" AbsoluteLayout.LayoutFlags="All" AbsoluteLayout.LayoutBounds="0,.5,1,0.8" IsGroupingEnabled="True" SeparatorVisibility="None" HasUnevenRows="True"  >
                <ListView.GroupHeaderTemplate >
                    <DataTemplate >
                        <ViewCell Height="60">
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="10*"/>
                                    <RowDefinition Height="90*"/>
                                </Grid.RowDefinitions>
                                <Label Text="" Grid.Row="0" BackgroundColor="{StaticResource PageBackgroundColor}" />
                                <Frame Style="{StaticResource FrameStyle}" Grid.Row="1" Margin="10,0,10,0" Padding="20,4,20,4">
                                    <Grid x:Name="FuelSationInfo">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="75*"/>
                                            <ColumnDefinition Width="25*"/>
                                        </Grid.ColumnDefinitions>
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="auto"/>
                                        </Grid.RowDefinitions>
                                        <Label Style="{StaticResource ListLabel}" Text="{Binding Name}" FontSize="{StaticResource MediumFontSize}" />
                                        <Button Style="{StaticResource ButtonStyle}" Grid.Column="1" IsEnabled="{Binding MapEnabled}" Text="Map"  FontSize="{StaticResource SmallFontSize}" Command="{Binding Source={x:Reference fuelStationsDetail}, Path=BindingContext.NavigateToStation}" CommandParameter="{Binding Source={x:Reference FuelSationInfo}, Path=BindingContext}"/>
                                    </Grid>
                                </Frame>
                            </Grid>
                        </ViewCell>
                    </DataTemplate>
                </ListView.GroupHeaderTemplate>
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <ViewCell Height="40">
                            <Frame Style="{StaticResource FrameStyle}" BackgroundColor="{StaticResource SecondaryColor}" Padding=" 20,5,20,0" Margin="10,-18,10,0">
                                <Grid >
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="*" />
                                    </Grid.RowDefinitions>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="75*"/>
                                        <ColumnDefinition Width="25*"/>
                                    </Grid.ColumnDefinitions>
                                    <Label Grid.Column="0" Grid.Row="0" Style="{StaticResource ListLabel}" Text="{Binding Type}" HorizontalTextAlignment="Center" FontSize="{StaticResource SmallFontSize}"/>
                                    <StackLayout Orientation="Horizontal" Grid.Column="1" Grid.Row="0">
                                        <Label  Style="{StaticResource ListLabel}" Text="{Binding Price}" 
                                                HorizontalOptions="EndAndExpand" HorizontalTextAlignment="End"  FontSize="{StaticResource SmallFontSize}"/>
                                        <Label Style="{StaticResource ListLabel}" FontSize="{StaticResource XSmallFontSize}"  Text="{Binding Source={x:Reference fuelStationsDetail}, Path=BindingContext.LocalCurrencySymbol}"/>
                                    </StackLayout>

                                </Grid>
                            </Frame>
                        </ViewCell>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>

how to add webservice reference in xamarin.forms portable project

$
0
0

Hi,

I'm seen the "Todo PCL" example from xamarin forms examples, and i try to add webservice reference, and can't appear the menu "add webservice reference" (Reference > right click at mouse button ), i in visual studio 2015 Update 2 portable project.

i was see the todoWCF example and its included webservice proxy setting in the portable solution.

How can i add and generate all objects related to wsdl webservice (proxy setting, etc) in the portable solution?

Regards
Javier Garcia

Getting error on Visual Studio 2017 for Xamarin.Forms iOS "Native linking failed"

$
0
0

iOS build failed while debugging, but it is working fine in iPhoneSimulator

Error info :

  1. Error Native linking failed, undefined symbol: _AudioServicesCreateSystemSoundID. Please verify that all the necessary frameworks have been referenced and native libraries are properly linked in. HelloWorld.iOS
  2. Error Native linking failed. Please review the build log. HelloWorld.iOS
  3. Error Native linking failed, undefined symbol: _AudioServicesPlaySystemSound. Please verify that all the necessary frameworks have been referenced and native libraries are properly linked in. HelloWorld.iOS

Note : I am not using any _AudioServices I dont know why this error is getting only in iPhone Device while it is working fine in iPhoneSimulator

Thank you,
Jitendra Jadav

Local Db distribution with app

$
0
0

Good Day, does anyone have a nice sample that shows how to distribute A sqlite DB Together with a Xamarin forms app (PCL).

I would need an Android , UWP, and IOS implementation of the file helper that picks up an existing DB file.

Thanks in advance


Xamarin forms master detail page has few issues in Xamarin Mac.

$
0
0
  1. Master detail page Menu icon is not getting displayed at all ( irrespective of having the icon in both resources as well as in image sets ).
  2. Screen flickers for every navigation that happens through the click of the option

I have tried several options, but nothing seems to sort this out. Any help would be greatly appreciated.

Xamarin Forms Version : 2.5

How to setup payment with debit card on xamarin forms?

$
0
0

I have a POS application build with Xamarin.Forms, inside xamarin forms how to setup payment with debit card?

Use a boolean to switch between two ObservableCollections in a ListView

$
0
0

Hello everyone :)

I have a boolean ("ShowChildrenDocumentsSetting") in a "SettingsViewModel" that I want to use to change the items source of a Listview.
The binding context of this Listview is a ViewModel with two ObservableCollections ("Documents" and "AllDocuments").
How can I change dynamically the ItemsSourceProperty of my Listview using this boolean to switch between those collections?

I tried using Datatrigger in my view's constructor but I didn't manage to make it work:

            DataTrigger dataTriggerTrue = new DataTrigger(typeof(ListView))
            {
                Value = "True",
                Binding = new Binding("ShowChildrenDocumentsSetting") { Source = Helper.SettingsViewModel }
            };

            Setter sourceSetterTrue = new Setter()
            {
                Property = ListView.ItemsSourceProperty,
                Value = new Binding("AllDocuments") { Source = this.BindingContext}
            };
            dataTriggerTrue.Setters.Add(sourceSetterTrue);
            listView.Triggers.Add(dataTriggerTrue);


            DataTrigger dataTriggerFalse = new DataTrigger(typeof(ListView))
            {
                Value = "False",
                Binding = new Binding("ShowChildrenDocumentsSetting") { Source = Helper.SettingsViewModel }
            };

            Setter sourceSetterFalse = new Setter()
            {
                Property = ListView.ItemsSourceProperty,
                Value = new Binding("Documents") { Source = this.BindingContext }
            };

            dataTriggerFalse.Setters.Add(sourceSetterFalse);
            listView.Triggers.Add(dataTriggerFalse);

Right now I'm doing it like this (see code below) in my view's constructor but it's not dynamic.
I need to recreate the page to see the change in the Listview's collection if I change the ShowChildrenDocuments value :

    if (Helper.SettingsViewModel.ShowChildrenDocuments) {
        listView.SetBinding(ListView.ItemsSourceProperty, "AllDocuments");
    } else {
        listView.SetBinding(ListView.ItemsSourceProperty, "Documents");
    }

Any idea on how this should be done ?
Thank you in advance !

When can we expect forms 3.0? What's the status of the pre-release

$
0
0

Hi everyone, long time no speak!

Been away from Xamarin land for a couple of years and was excited about Forms 3.0; last I heard it was out Q4, and we're at April now practically, without a peep; just a pre-release a few months back..

Is it gonna get release? If so when? Is it wise to start a new project in Forms 3.0? So many questions!!! :)

how to create a table in xamarin in which i putt data dynamically

$
0
0

hello, plz help me i am work on a project in which i want to create a table for only show the data, but i want to insert data in table dynammically like listview i also want the header of that table can also putt dynammically.

XForms 1.3.2: Can OnPlatform be used with ResourceDictionary.Styles?

$
0
0

Does anyone of if you can specify OnPlatform declarations when using Styles? I've tried a few different things but can't get it to work. My last attempt looked liked this:

`

<ResourceDictionary>
    <Style x:Key="ButtonStyle" TargetType="Button">
        <Setter Property="VerticalOptions" Value="Center" />
        <Setter Property="HorizontalOptions" Value="Center" />

        <Style.Setter.Property.HeightRequest>
            <OnPlatform x:TypeArguments="x:Double" iOS="94" Android="100" />
        </Style.Setter.Property.HeightRequest>

        <Style.Setter.Property.WidthRequest>
            <OnPlatform x:TypeArguments="x:Double" iOS="94" Android="100" />
        </Style.Setter.Property.WidthRequest>
    </Style>
</ResourceDictionary>

`

Mixing native UWP pages and Xamarin Forms pages

$
0
0

I am trying to get a demo working that will allow me to include navigation native UWP pages and pages build using Xamarin Forms.

When I try and use the rootFrame to navigate to the first XF page I get a AccessViolationException from this code

return this._frame.Navigate(viewType, parameter);

Any thoughts as to why this might happen?

I have tried forcing the code to run on the UI thread but that didn't help
I have seen reports of that exception from WinRT when XAML pages are defined in a different assembly but I have tried navigating to native [ages in a second assembly and that worked fine so i don't think that is the issue.


How to have multiple pages inside a page

$
0
0

Hi,

I need to have two section on the same page.
The top section(or 1st section) being the static on the page while the bottom(or 2nd section) section having multiple modelling pages on it.

Kindly suggest how it is achievable.

Thanks in advance.

Bottom navigation bar unwanted space

$
0
0

This my Xaml code:




    <StackLayout VerticalOptions="EndAndExpand" Padding="0" Spacing="0" Margin="0" HorizontalOptions="FillAndExpand"
                      RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1}"
                      RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.90}"
                      RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.1}">

        <Grid   BackgroundColor="#e8eaf6" Padding="0" Margin="0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>

            <StackLayout Orientation="Vertical" Grid.Column="0" HorizontalOptions="CenterAndExpand" VerticalOptions="Center">
                <Image  Source="bb_YayinEkrani.png"  WidthRequest="30" HeightRequest="30" Opacity="0.6" />

            </StackLayout>

            <StackLayout Orientation="Vertical"  Grid.Column="1"  HorizontalOptions="CenterAndExpand" VerticalOptions="Center">
                <Image Source="bb_HaberMasasi.png" WidthRequest="30" HeightRequest="30"  Opacity="0.6">
                    <Image.GestureRecognizers>
                        <TapGestureRecognizer Tapped="ImgHaberMasasi_Tapped"/>
                    </Image.GestureRecognizers>
                </Image>

            </StackLayout>

            <StackLayout Orientation="Vertical"  Grid.Column="2"  HorizontalOptions="CenterAndExpand" VerticalOptions="StartAndExpand">

                <Image  Source="aalogo2.png"  WidthRequest="40" HeightRequest="40" >
                    <Image.GestureRecognizers>
                        <TapGestureRecognizer Command="{Binding SlideOpenCommand}" Tapped="Logo_Tapped"/>
                    </Image.GestureRecognizers>
                </Image>
            </StackLayout>
            <StackLayout Orientation="Vertical"  Grid.Column="3"  HorizontalOptions="CenterAndExpand" VerticalOptions="Center">
                <StackLayout Orientation="Horizontal" HorizontalOptions="CenterAndExpand" VerticalOptions="Center">
                    <Image  Source="bb_Bell.png"  WidthRequest="30" HeightRequest="30" Opacity="0.6"/>
                   <badge:BadgeView Text="21" BadgeColor="Red" VerticalOptions="Start" HorizontalOptions="End" />
                </StackLayout>

            </StackLayout>
            <StackLayout Orientation="Vertical"  Grid.Column="4"  HorizontalOptions="CenterAndExpand" VerticalOptions="Center">
                <StackLayout Orientation="Horizontal" HorizontalOptions="Center" VerticalOptions="Center">
                    <Image  Source="bb_Profile.png"  WidthRequest="30" HeightRequest="30" Opacity="0.6">
                        <Image.GestureRecognizers>
                            <TapGestureRecognizer Tapped="ImgProfile_Tapped"/>
                        </Image.GestureRecognizers>
                    </Image>
                    <badge:BadgeView Text="8" BadgeColor="Red" VerticalOptions="Start" HorizontalOptions="End" />
                </StackLayout>

            </StackLayout>
        </Grid>
    </StackLayout>
</RelativeLayout>

Xamarin.Auth and Twitter Login Error

$
0
0

Hello,

I'm a newbie in Xamarin and I'm trying to achieve something simple... I have a button and I want to Login with Twitter (I'm working on Android).

On shared code I have:
`public void StartTwitterLogin()
{
var auth = new OAuth1Authenticator(
consumerKey: "*******************",
consumerSecret: "*********************************************************",
requestTokenUrl: new Uri(twitter.requestTokenUrl),
authorizeUrl: new Uri(twitter.authorizeUrl),
accessTokenUrl: new Uri(twitter.accessTokenUrl),
callbackUrl: new Uri(twitter.callbackUrl)
);
auth.AllowCancel = false;
auth.Completed += OnAuthCompleted;
auth.Error += OnAuthError;
var presenter = new Xamarin.Auth.Presenters.OAuthLoginPresenter();
presenter.Login(auth);

            }

`
So I have this function bonded to my button. But when I click it, it launches an alert saying "socket not connected"... anyone can help?

Thank you in advance

Capture app crash report and write into text file

$
0
0

I would like to ask is there even possible to capture app crash report from the phone and write it into another text file?

[android] label renderer apply to all labels

$
0
0

I have forms app, and I have custom label as following,

public class HtmlFormattedLabel : Label
    {
        public float mySize { get; set; }
    }

and I have custom renderer in both android and ios as following:

Android:

[assembly: ExportRenderer(typeof(HtmlFormattedLabel), typeof(HtmlFormattedLabelRenderer))]
namespace HBRS.Droid.Renderers
{
    public class HtmlFormattedLabelRenderer : LabelRenderer
    {

        public HtmlFormattedLabelRenderer(Context context) : base(context)
        {

        }
        protected override void OnElementChanged(ElementChangedEventArgs<Label> e)
        {
            base.OnElementChanged(e);

            HtmlFormattedLabel view = (HtmlFormattedLabel)Element;
            if (view == null) return;

            Control.Gravity = Android.Views.GravityFlags.Right;
            Control.SetTextSize(Android.Util.ComplexUnitType.Sp, view.mySize);

            if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.N)
                Control.SetText(Html.FromHtml(view.Text.ToString(), FromHtmlOptions.ModeLegacy), TextView.BufferType.Normal);
            else
                Control.SetText(Html.FromHtml(view.Text.ToString()), TextView.BufferType.Normal);
        }
    }
}

iOS

    [assembly: ExportRenderer(typeof(HtmlFormattedLabel), typeof(HtmlFormattedLabelRenderer))]
    namespace HBRS.iOS.Renderers
    {
        public class HtmlFormattedLabelRenderer : LabelRenderer
        {
            protected override void OnElementChanged(ElementChangedEventArgs<Label> e)
            {
                base.OnElementChanged(e);

                var view = (HtmlFormattedLabel)Element;
                if (view == null) return;
                UIStringAttributes te = new UIStringAttributes();
                var attr = new NSAttributedStringDocumentAttributes();
                var nsError = new NSError();
                attr.DocumentType = NSDocumentType.HTML;
                attr.StringEncoding = NSStringEncoding.UTF8;
                attr.ViewMode = NSDocumentViewMode.PageLayout;
                Control.AttributedText = new NSAttributedString(view.Text, attr, ref nsError);
            }
        }
    }

the problem that in android, the renderer applied to all labels in the app, (when I change size of the custom label all the label sizes changes)

Viewing all 58056 articles
Browse latest View live


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