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

New issue missing constructor JniHandleOwnership with XF 2.2 on Android

$
0
0

Strange. I just updated to XF 2.2 now that both OxyPlot and DevExpress supports it. I ran into a new issue on Android.

My app needs to be able to tap on an OxyPlot and get plot objects that were tapped. Since this isn't builtin, I extended PlotView like this:

public class TapPlotView : PlotView
{
    public static BindableProperty DrillDownCommandProperty = BindableProperty.Create<TapPlotView, ICommand>(x => x.TapCommand,
        null,
        BindingMode.OneWay
    );
    public ICommand TapCommand {
        get { return (ICommand)GetValue(DrillDownCommandProperty); }
        set { SetValue(DrillDownCommandProperty, value); }
    }

    public void OnItemTapped(IEnumerable<HitTestResult> results)
    {
        if (TapCommand != null)
            TapCommand.Execute (results);
    }
}

I then implemented Renderers for both iOS and Android. iOS renderer adds a TapGestureRecognizer and works fine. However, my Android renderer:

public class TapPlotViewRenderer : PlotViewRenderer
{
    private const int HIT_TOLERANCE = 15;

    protected override void OnElementChanged (ElementChangedEventArgs<PlotView> e)
    {
        base.OnElementChanged (e);
        if (Control != null) {
            Control.Touch += delegate(object sender, TouchEventArgs tea) {
                //Don't steal touch event which prevents pan/zoom
                tea.Handled = false;
                double scale = OxyPlot.Xamarin.Android.PlotView.Scale;
                if(tea.Event.Action != MotionEventActions.Down)
                    return;
                IEnumerable<HitTestResult> results = Control.Model.HitTest(new HitTestArguments(new ScreenPoint(tea.Event.GetX() / scale,tea.Event.GetY() / scale),HIT_TOLERANCE));
                ((TapPlotView)Element).OnItemTapped(results);
            };
        }
    }
}

is failing with XF2.2 complaining about missing constructor (IntPtr,JniHandleOwnership) in PlotView. My google searches says this means something else is bad. Strange that this worked fine on Android for XF2.1.

Any ideas?


Why doesn't this listview adjust her height?

$
0
0

public EventsPage ()
{

        Title="   Events";

        Methods.events.Add (new Event{id="1", germanDisplayName="ViaThea", polishDisplayName="1", date=DateTime.Now, isFavourite=true, description="...",imageUrl="url", location="loc"});

        ...

        Methods.sortEvents ();
        Methods.groupEvents ();

        var template = new DataTemplate(typeof(EventCell));
        var headerTemplate = new DataTemplate(typeof(GroupHeaderCell));

        var listview = new ListView {
            ItemsSource = Methods.groupedEvents,
            IsGroupingEnabled = true,
            GroupHeaderTemplate = headerTemplate,
            HasUnevenRows = true,
            RowHeight = 85,
            BackgroundColor = Color.White,
            ItemTemplate = template,
            SeparatorVisibility = SeparatorVisibility.Default,
            SeparatorColor = Color.FromHex("#F5F5F5"),
            VerticalOptions = LayoutOptions.FillAndExpand
        };

        listview.ItemTapped += this.Tapped;

        var absolutLayout = new AbsoluteLayout{BackgroundColor = Color.Aqua};
        AbsoluteLayout.SetLayoutBounds (listview, new Rectangle (0, 0, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize));
        AbsoluteLayout.SetLayoutFlags (listview, AbsoluteLayoutFlags.PositionProportional);

        absolutLayout.Children.Add (listview);

        Content = absolutLayout;

        InitializeComponent ();

    }

Signature Pad Droid. Resouce Designer issues.

$
0
0

Hi,
I was just dabbling with the Signature Pad, to have it implemented in a PCL project. That uses Xamarin forms,

Here is what I did so far:

  • I installed a nuget package Acr.XamForms.Signature Pad in mt shared project.
  • I installed Signature pad nuget in my Droid project.
  • I installed Signature Pad nuget in my iOs project.

  • In my shared project. I did the following:

XAML View:



In the code behind this is what is present:-

public partial class Page_SignaturePad : ContentPage
{
    public Page_SignaturePad()
    {
        InitializeComponent();

    }

    //Capture the user's signature.
    async void OnSaveSignature(object sender, EventArgs e)
    {
        try
        {
            var signature = padView.GetImage(Acr.XamForms.SignaturePad.ImageFormatType.Png);
            using (BinaryReader br = new BinaryReader(signature))
            {
                var result = br.ReadBytes((int)signature.Length);

            }
        }
        catch(Exception ex)
        {
            Helper_ErrorHandling.SendErrorToServer(ex);
        }
    }
}

It works well on iOS. However on Android when i try to build the project i get the following error: (attached screenshot)

Has anyone encountered and solved a similar issue.

I am on Xam forms 1.5.6417 . I believe that is what Signature pad needs

WebView without heightRequest

$
0
0

I need WebView without height Request. There are some helpful posts in there about Auto HeightRequest. Their solutions sounds well if the app request the client on the web. I load the html content from a string, it does not sounds working perfectly well, in some test cases, the height request doesn't work well, there are still some content hidden.
I tried to use the custom Renderer and use the javascript to post back page height and put it in the height request. It doesn't work too.
Does anyone face the same situation?

GridView || ItemsControl + WrapPanel

$
0
0

My app makes heavy use of an interface consisting of a wrapping grid of icons. The same functionality is provided by the GridView control in UWP. It would be wonderful if Xamarin.Forms provided an implementation of the GridView control. In the meantime, what are my options to replicate this functionality. There doesn't even appear to be an ItemsControl and a WrapPanel (which is how I could get a primitive GridView experience going in WPF/UWP).

TabbedPage within a ContentPage

$
0
0

Hello guys,

I need to put a tabbed page within a content page in Xamarin forms .
I need because I like to have a header with an image and some text above the tabs in the tabbed page .

Someone ever needed to do something?

Thank you.

Google Style Navigation Drawer

$
0
0

I followed this code to design a basic master detail navigation drawer

https://developer.xamarin.com/guides/xamarin-forms/user-interface/navigation/master-detail-page/

Where can i find examples or samples that will enable me to recreate a sidebar very similar to Google? I am looking for one which also has the settings menu item fixed to the bottom of the navigation drawer. Ideally id like to be able to click on the profile image and navigate to a profile page too.

I would love to find a version of this that i could use with visual studio, this is what im looking for: https://github.com/mikepenz/MaterialDrawer

Someone can help me to load a byte to Image of Xamarin Forms array?

$
0
0

I tried with this, But always is empty

myImage.source = ImageSource.FromStream(() => new MemoryStream(imageAsBytes));

any tips would be very very ver helpful.


How to set the value of the MainActivity's Theme

$
0
0

I create a Xamarin.Forms project.I set the value of the MainActivity's Theme to "@android:style/Theme.NoTitleBar" on Android project.When I debug the Android project,it occurs an exception that shown "Object reference not set to an instance of an object" on the code "LoadApplication(new App());".What can I do with this.

Difference between iOS and Android implementations of ListView ScrollTo method

$
0
0

I have a ListView with its Header set. What I want to do is hide the header when the listview is shown for the first time. On Android, I was able to accomplish this with

myListView.ScrollTo(items.ElementAt(0), ScrollToPosition.Start, false);

On iOS, this behavior does not function the same. To accomplish the same effect, I need to increase the ElementAt index by 1. It seems as if the header is treated just like another element.

Is this how iOS works or is it a bug with XF?

The method InitializeComponent doesn't exist.

$
0
0

I create a Xamarin.Forms project by vs2015 update2.I add a xaml page in the shared project and it has no problem.Then I restar the vs and open the solution,it shows error message that means the method InitializeComponent doesn't exist.But it can run ok.When I add a new xaml page,the error message faded away.Then I delete the new xaml page,the same error message shown again.

How to specify the color shown prior to Cells in a ListView being painted?

$
0
0

When scrolling a ListView, for a fraction of a second the background of the area that will be painted with the next ViewCell that comes into view flashes up briefly in dark gray on a low-spec Windows 10 phone (using a UWP build), before being painted with the expected cell contents. Whilst the painting of the cell will want to be optimized, it would be good to also have the background instantly in my intended background color rather than the dark gray, so that it is less obvious. Does anybody know where that color can be changed? It's not the BackgroundColor property of the ListView, nor the BackgroundColor of the View in the ViewCell.

Upload your iOS and Android Apps to HockeyApp via PowerShell

$
0
0

Hey all, just wanted to share a bit of what I was working on this week. I have a need to be able to upload my apps to HockeyApp, but it has to be via PowerShell since I'm using Octopus Deploy for my deployments.

I first took a look around to see if anyone had already worked on something, and I came across this. The unfortunate problem with this is that it's not very reusable or flexible. I took some principles from it and came up with my own version.

The following GIST has the ability to list all versions, update an existing version, or upload a new version.

Please feel free to comment or expand as you see fit.

HockeyApp.psm1

Usage:

  Import-Module "$here\modules\hockeyapp.psm1"
  $params = @{
      file="hockeyapp.ipa"
      apiKey = '4567abcd8901ef234567abcd8901ef23'
      appId = '1234567890abcdef1234567890abcdef'
      teams = 12,13,14
      notify = 1
      status = 2
      version = 1234
  }

  Push-ToHockeyApp @params -overwrite

How can I force hide the keyboard (as a workaround for a Xamarin Forms bug)

$
0
0

I unfortunately can't share the code as this is for a client, but I'll explain the situation.

I have an Entry and a button. Clicking the button hides the entry. If I first click on the entry (bring up the keyboard), then click the button to hide the entry while the keyboard is shown, the keyboard does not go away.

I have some questions:

  1. Is this a bug? It seems as if making an Entry's IsVisible should make the keyboard disappear but it does not.
  2. Shouldn't a keyboard disappear by default when clicking a button?
  3. How can I force the keyboard to hide as a workaround to this issue when the button is clicked.

set volume


Gorila Player

Slider binded and set event

$
0
0

Hi, I have a slider binded

<?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="TestCase6.test"
   xmlns:local="clr-namespace:TestCase6;assembly=TestCase6">
  <StackLayout>
    <Slider Maximum="1000" Minimum="100" Value="{Binding Path=DValue, Mode=TwoWay}" >
          <Slider.BindingContext>
            <local:testvm />
          </Slider.BindingContext>
    </Slider>
  </StackLayout>
</ContentPage>

namespace TestCase6
{
    class testvm : INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;
        double _dvalue = 500;
        public static int count = 0;
        public double DValue
        {
            get
            {
                return _dvalue;
            }
            set
            {
                if (_dvalue != value)
                {
                    count++;
                    _dvalue = value;
                    if (PropertyChanged != null)
                    {
                        PropertyChanged(this,
                            new PropertyChangedEventArgs("DValue"));
                    }
                }
            }
        }
    }
}

When drag the slider I have a lot of set events of the DValue.

Is possibile have set events only a the end of the drag?

Thanks in advanced.

How to update Xamarin.Forms from 2.0.0.6482 to 2.2.0.31

$
0
0

I create a Xamarin.Forms project and it uses the 2.0.0.6482 version of Xamarin.Forms .
I update the version from 2.0.0.6482 to 2.2.0.31.
When I try to build the Android project,it shows error as follows:
image

MasterDetail Icon not shown if the page is navigated to from Login Page at start

$
0
0

So my app tries at the start to log in with saved between sessions login information.
Something like this:

public App()
{
    if (DoLogin(UserData) == LoginStatus.Success)
        MainPage = new NavigationPageNoLine(new MainAppPage());
    else
        MainPage = new NavigationPageNoLine(new LoginPage());
}

where MainAppPage is a MasterDetailPage.

If there is UserData saved between the sessions of the app, then the MainPage is the MasterDetailsPage where everything is in place and the MasterDetails icon appears as it should be:

But when there is no UserData saved, the LoginPage appears, where, after the login process is completed, I set:

Application.Current.MainPage = new NavigationPageNoLine(new MainAppPage());

Everything is ok except in this case the master details icon does not appear in the page:

The drawer is working perfectly in both cases. Only the icon disappears in the Login scenario.
How to make sure the icon appears in all cases?
Thank you in advance for any help.

How to plot data in a data grid with appropriate heading while I have data source

$
0
0

I have created a web service which stores the values in an array, But not able to show those data in an grid using XAML.

In Xamal.CS file I have created the following for loop to store the values from web service:-

RootObject weatherData = new RootObject();

weatherData = JsonConvert.DeserializeObject(weatherJson);

string[] dt = new string[weatherData.cnt];
double[] min_temp= new double[weatherData.cnt];
double[] max_temp = new double[weatherData.cnt];
double[] humidity = new double[weatherData.cnt];
string[] descrip = new string[weatherData.cnt];

for(int i=0;i< weatherData.cnt;i++)
{
min_temp[i] = weatherData.list[i].temp.min;

                max_temp[i] = weatherData.list[i].temp.max;

                humidity[i] = weatherData.list[i].humidity;

                descrip[i] = weatherData.list[i].weather[1].description;

                dt[i] = UnixTimeStampToDateTime(weatherData.list[i].dt);

            }

this weatherData is the root of my web service, How could I show the min_temp, max_temp, humidity, dt value using a data grid?

Viewing all 58056 articles
Browse latest View live


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