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

two columns in one list view

$
0
0

I want to see two columns in one listview . (something like grid but grid is not scrollable) . I need this because I want list view item scrollable.


Xamarin.Essentials Web Authenticator

$
0
0

Why i get exception "You must subclass the WebAuthenticatorCallbackActivity and create an IntentFilter for it which matches your callbackUrl." when set urn:ietf:wg:oauth:2.0:oob in DataScheme?

My redirectUrl = "urn:ietf:wg:oauth:2.0:oob://" and i try set just "urn:ietf:wg:oauth:2.0:oob" and again get this exception.

Disable Navigation Bar/Enable InteractivePopGestureRecognizer causes navigation/popasync issue

$
0
0

Here is exactly what is happening to me...

https://github.com/wix/react-native-navigation/issues/428#issuecomment-260427414

Basically, I have a MasterDetail page and the Detail page is a listview. When tapping on an item, PushAsync a new page with no Navigation bar, but I have InteractivePopGestureRecognizer enabled so the user can just swipe "back" in the navigation. Most of the time it works, but the gif you see in the above link happens and I do not know why.

I have NavigationPage.SetHasNavigationBar(this, false); on the page itself...

and its renderer...

[assembly: ExportRenderer(typeof(ChannelPage), typeof(ChannelPageCustomRenderer))] namespace MyApp.iOS { public class ChannelPageCustomRenderer : PageRenderer, IUIGestureRecognizerDelegate { public ChannelPageCustomRenderer() {} public override void ViewWillAppear(bool animated) { base.ViewWillAppear(animated); ViewController.NavigationController.InteractivePopGestureRecognizer.Enabled = true; ViewController.NavigationController.InteractivePopGestureRecognizer.Delegate = new UIGestureRecognizerDelegate(); } } }

Direct link to gif: http://i.imgur.com/F3zBwH3.gifv

Where is whitespace between burger icon and search bar coming from?

$
0
0

How can I get the SearchBar to appear immediately right of the hamburger icon (please see image), where is the white space coming from? I cant find it.

Iv set stackLayout and SearchBar inside NavigationPage to `HorizontalOptions="StartAndExpand" VerticalOptions="StartAndExpand"

is it from padding from the burgerIcon button. How can I check, I cant find it either in the code?

Thanks for any replies

 <?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="WineShop.Views.Products">
    <NavigationPage.TitleView>
        <StackLayout HorizontalOptions="StartAndExpand" VerticalOptions="StartAndExpand" Orientation="Horizontal">
            <SearchBar x:Name="SearchBar" TextChanged="SearchBar_TextChanged" HorizontalOptions="StartAndExpand" Placeholder="Search..." PlaceholderColor="Gray" TextColor="White" VerticalOptions="StartAndExpand"/>
        </StackLayout>
    </NavigationPage.TitleView>
    <ContentPage.ToolbarItems>
        <ToolbarItem Name="shoppingCartImg" Icon="shoppingCartImg.png" Priority="0" Order="Primary" Activated="ShoppingCartClicked"/>
        <ToolbarItem Text="{Binding NoItemsInShoppingCart}" Priority="0" Order="Primary" Activated="ShoppingCartClicked"/>
    </ContentPage.ToolbarItems>
    <ContentPage.Content>
        <Grid>

Allow a single place to handle back button requests with Async support

$
0
0

Summary

Currently there are different ways to handle the back button request (understandable), but for example on Android one must handle the hardware and software button separably(software one is a bit hacky). Can we look into a possible solution to bring all these into one callback? i.e. App.cs OnBackButton event or virtual method.

API Changes

A addition of a virtual Task of bool method on App.cs

protected override Task OnBackButtonAsync(BackButtonArgs args)
{
return OnBackButtonAsync(args);
}

Or a Request page Pop method on on App.cs

protected override Task OnPagePoppingAsync(Page page)
{
return OnPagePoppingAsync(page);
}

Intended Use Case

To check if there are any unsaved changes on a page by either method :

protected override async Task OnBackButtonAsync(BackButtonArgs args)
{
var page = Args.Page;

    var viewmodel = page.BindingContext as Viewmodel;

    var result = await viewmodel.CheckUnSavedChangesAsync();

    return result ;
    }

Or a Request page Pop method on on App.cs

protected override async Task OnPagePoppingAsync(Page page)
{
var viewmodel = page.BindingContext as Viewmodel;

    var result = await viewmodel.CheckUnSavedChangesAsync();

    return result ;
    }

Alternative way to get variable in code behind without x:Name

$
0
0

Hi All,

Quick question I know it might sound stupid but I've been creating XAML pages a lot but now I want to try to approach it from using a JSON data to create a form based layout. So I have created a JSON and its classes and populated it with dummy data. the JSON has load of questions and a field to determine what the control will be (Entry, Datepicker, Picker, Editor etc etc.) I create the layout on load but when i create a button at the bottom to send that data back into a JSON object to upload to an API I am not sure how to get that form data back as you cant set the x:Name property in code behind and in my save function it can't see the control variable. I hope this makes sense and below is my code i use to bring back the form layout.

`public void LoadFormTemplate()
    {
        var generate = new CreateDummyData().CreateTestData();

        var ParentLayout = new StackLayout();
        foreach (Questions q in generate.Questions)
        {
            if (q.QuestionType == "Entry")
            {
                var ChildLayout = new Grid();

                ChildLayout.Padding = new Thickness(20);

                ChildLayout.ColumnDefinitions.Add(new ColumnDefinition());
                ChildLayout.ColumnDefinitions.Add(new ColumnDefinition());
                ChildLayout.RowDefinitions.Add(new RowDefinition());

                Label label = new Label { Text = q.QuestionName };
                Entry entry = new Entry { StyleId = "Question1Entry" };

                Grid.SetRow(label, 0);
                Grid.SetRow(entry, 0);
                Grid.SetColumn(label, 0);
                Grid.SetColumn(entry, 1);

                ChildLayout.Children.Add(label);
                ChildLayout.Children.Add(entry);

                ParentLayout.Children.Add(ChildLayout);
            }
            else if (q.QuestionType == "Picker")
            {

                var ChildLayout = new Grid();
                ChildLayout.Padding = new Thickness(20);

                ChildLayout.ColumnDefinitions.Add(new ColumnDefinition());
                ChildLayout.ColumnDefinitions.Add(new ColumnDefinition());
                ChildLayout.RowDefinitions.Add(new RowDefinition());

                Label label = new Label { Text = q.QuestionName };
                Picker entry = new Picker();

                foreach (Fields f in q.Fields)
                {
                    entry.Items.Add(f.Field);
                }

                entry.Title = "Please Select";

                Grid.SetRow(label, 0);
                Grid.SetRow(entry, 0);
                Grid.SetColumn(label, 0);
                Grid.SetColumn(entry, 1);

                ChildLayout.Children.Add(label);
                ChildLayout.Children.Add(entry);
                ParentLayout.Children.Add(ChildLayout);

            }
            else if (q.QuestionType == "DatePicker")
            {
                var ChildLayout = new Grid();
                ChildLayout.Padding = new Thickness(20);

                ChildLayout.ColumnDefinitions.Add(new ColumnDefinition());
                ChildLayout.ColumnDefinitions.Add(new ColumnDefinition());
                ChildLayout.RowDefinitions.Add(new RowDefinition());

                Label label = new Label { Text = q.QuestionName };
                DatePicker entry = new DatePicker { };

                Grid.SetRow(label, 0);
                Grid.SetRow(entry, 0);
                Grid.SetColumn(label, 0);
                Grid.SetColumn(entry, 1);

                ChildLayout.Children.Add(label);
                ChildLayout.Children.Add(entry);

                ParentLayout.Children.Add(ChildLayout);

            }
            else if (q.QuestionType == "Editor")
            {
                var ChildLayout = new Grid();
                ChildLayout.Padding = new Thickness(20);

                ChildLayout.ColumnDefinitions.Add(new ColumnDefinition());
                ChildLayout.RowDefinitions.Add(new RowDefinition());
                ChildLayout.RowDefinitions.Add(new RowDefinition());

                Label label = new Label { Text = q.QuestionName };
                Editor entry = new Editor { HeightRequest = 100 };

                Grid.SetRow(label, 0);
                Grid.SetRow(entry, 1);
                Grid.SetColumn(label, 0);
                Grid.SetColumn(entry, 0);
                entry.StyleId = "Editorquestion";

                ChildLayout.Children.Add(label);
                ChildLayout.Children.Add(entry);
                ParentLayout.Children.Add(ChildLayout);
            }
            this.Content = ParentLayout;
        }

        var submit = new Button { Text = "Submit Vehicle Check" };

        ParentLayout.Children.Add(submit);

        submit.Clicked += SaveJson;
    }

    private async void SaveJson(object sender, EventArgs e)
    {
       var result = await DisplayAlert("Farmer","Are you sure you want to submit the vehicle check","Yes","No");

        if (result)
        {

        }
    }`

Chart

$
0
0

I need to do chart like this

Does anyone have any idea what plugin I could use that doesn't cost a fortune?

Thankyou in advance,
Davide.

Xamarin Date Slider Chart Control?

$
0
0

Hello :) I am looking for a control that does something similar to the image below. It is a date slider that has data for each day which displays as a chart and is selectable and clickable. Any ideas? Thank you!


How to add an application to TestFlight using Xamarin Forms?

$
0
0

How to add an application to TestFlight using Xamarin Forms?

can the urho scene background be transparent?

$
0
0

I created a scene to display 3d models using urhosharp
but it it like this:

it is black,can it be transparent?so it can display the lower views?only display the models?

How to bind list in Content View?

$
0
0

Hello,
In my project, I'm adding one content page in that content page I'm binding some content views using DataTemplate now I want to add a new content view that has list bindings on all of the above content views. I tried but the data not binding.

Firebase push notification message different languages

$
0
0

How I could display push notifications firebase messages in the same language as the phone.
If my backend sends Title="Hello" Body="Hi World", I want this message to be displayed in the configured language of the phone.

how to Detect Touch event EVERYWHERE !?

$
0
0

Hello,

i created a View component that i use in every page of my application mobile.
in this view component i want to detect every touch on the root page ( i know how to detect touch on my component by adding GestureRecognizers )

i think it's possible to handle this information because in debug mode every time i touch the screen a line on the console appear :
07-26 10:24:17.541 I/ViewRootImpl(29702): ViewRoot's Touch Event : ACTION_UP
07-26 10:24:18.149 I/ViewRootImpl(29702): ViewRoot's Touch Event : ACTION_DOWN

so if i could handle this event in my application ... but i don't know how !

Thx to help me ^^

How to slowdown sensor speed? (gyroscope, accelerometer..)

$
0
0

Hi, I am working on my own inactivity monitor and I am using now gyroscope sensor to get data.

My code:

    public void StartGyroscope()
    {
        SensorSpeed speed = SensorSpeed.Default;
        Xamarin.Essentials.Gyroscope.Start(speed);
        GyroscopeReadData();
    }

private void GyroscopeReadData()
    {
        Xamarin.Essentials.Gyroscope.ReadingChanged += Gyroscope_ReadingChanged;
    }

    void Gyroscope_ReadingChanged(object sender, GyroscopeChangedEventArgs e)
    {
        var data = e.Reading;

        var accX = data.AngularVelocity.X.ToString();
        var accY = data.AngularVelocity.Y.ToString();
        var accZ = data.AngularVelocity.Z.ToString();
...
}

This is working good, but for me it is too fast. My variables accX, accY... changing aprox 10x per second. I read, that instead of Sensor.Speed.Default I can use int in milisecond, but when I try this:

Xamarin.Essentials.Gyroscope.Start(1000);

I get error:

cannot convert from 'int' to 'Xamarin.Essentials.SensorSpeed'

Maybe someone know, how to set this milisecond or how to simply get data from sensor every 1 second?

Tab key not listening for CustomViewRenderer in Xamarin forms iOS

$
0
0

I have a xamarin forms grid and a written custom renderer for that grid in xamarin forms iOS platform. And applied BecomeFirstResposnder to that CustomRenderer on OnElementPropertyChanged. Added UIKeyCommand "\t " to the UIViewController. UpArrow,DownArrow, LeftArrow every key is listening except Tab and Shift+Tab Key. Kindly, please help me.

//CustomRenderer for Xamarin Forms Grid

protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
{
  base.OnElementPropertyChanged(sender, e);
  this.BecomeFirstResponder();
   if (this.KeyPageRenderer == null)
   {
     this.KeyPageRenderer = this.GetSfPageRenderer(this.GetControl());
     if (this.KeyPageRenderer != null)
     {  
      UIKeyCommand KeyTab = UIKeyCommand.Create(new NSString("\t"), 0, new ObjCRuntime.Selector("KeyRecV:"));
      this.KeyPageRenderer.AddKeyCommand(KeyTab);
     }
   }
}

internal UIViewController GetSfPageRenderer(UIView view)
{
  if (view != null)
  {
   var responder = (UIResponder)view;
   while (responder != null && !(responder is UIViewController))
   { 
    responder = responder.NextResponder;
   }
   return responder as UIViewController;
  }
  return null;
}

public override bool CanBecomeFirstResponder
{
 get
 {
  return true;
 }
}
[Export("KeyRecV:")]
private void Excute(UIKeyCommand keyCommand)
{
 if ((keyCommand.Input as NSObject).Description == "\t")
 {

 }
}

How to get child element access of collection view without using mvvm in xamarin forms?

$
0
0

this is my code:

<StackLayout HeightRequest="40" VerticalOptions="FillAndExpand" WidthRequest="40"> <Label FontSize="16" HorizontalOptions="Center" Text="+" TextColor="Black" VerticalOptions="CenterAndExpand" VerticalTextAlignment="Center"> <Label.FontFamily> <OnPlatform x:TypeArguments="x:String"> <On Platform="Android" Value="SFPro.ttf#Bold" /> </OnPlatform> </Label.FontFamily> </Label> <StackLayout.GestureRecognizers> <TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped" /> </StackLayout.GestureRecognizers></StackLayout>

 <StackLayout HeightRequest="40" VerticalOptions="FillAndExpand" WidthRequest="40"> <Label FontSize="16" HorizontalOptions="Center" Text="{Binding prod_qty}" x:Name="lblqty" TextColor="#00C569" VerticalOptions="CenterAndExpand" VerticalTextAlignment="Center"> <Label.FontFamily> <OnPlatform x:TypeArguments="x:String"> <On Platform="Android" Value="SFPro.ttf#Bold" /> </OnPlatform> </Label.FontFamily> </Label> </StackLayout>

This code is in collection view i am generating a source in .cs file and have set the source to its collection view. i want to access and modify lbl_qty value by clicking TapGestureRecognizer_Tapped but i don't know mvvm right now. please help.

Change SrollPosition in CollectionVIew

$
0
0

Is it possible to set a specific scroll position? Without to use an item.
Example scroll to e.VerticalOffset=100;

Xamarin UITextView Binding in Code

$
0
0

We are developping a xamarin forms app in VS2019 where we require the rtf funcionality of the native UITextView. We implemented this with an interface and a platform implementation as shown below - which works fine. What we are missing is how to bind this view to the viewmodel - as the UI view is added to the view page in code. Would appreciate some advice.

UITextView textView = new UITextView {AllowsEditingTextAttributes = true};
var rtfstring = new NSAttributedString(rtfstring, new NSAttributedStringDocumentAttributes { DocumentType = NSDocumentType.RTF }, ref error);

textView.AttributedText = rtfstring;
stackLayout.Children.Add(textView);

Shell.SearchHandler ERROR. BUG?

$
0
0

Hi, after updating to xforms 5, SearchHandler incorrectly displays ...
Tested on emulator and on physical device, with android 9, 10, 11.
I also downloaded the updated xanimals example and the error is present.

It doesn't happen with xforms 4.8.
Tips?

Xamarin UITextView Binding in Code

$
0
0

We are developping a xamarin forms app in VS2019 where we require the rtf funcionality of the native UITextView. We implemented this with an interface and a platform implementation as shown below - which works fine. What we are missing is how to bind this view to the viewmodel - as the UI view is added to the view page in code. Would appreciate some advice.

UITextView textView = new UITextView {AllowsEditingTextAttributes = true};
var rtfstring = new NSAttributedString(rtfstring, new NSAttributedStringDocumentAttributes { DocumentType = NSDocumentType.RTF }, ref error);

textView.AttributedText = rtfstring;
stackLayout.Children.Add(textView);

Viewing all 76418 articles
Browse latest View live


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