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

Frame.BorderRadius

$
0
0

Is there any way to change border radius on Frame? Or maybe there is another static control with rounded corners?


Display image in Xamarin Forms app sourced from post method on RESTful service

$
0
0

Hi all, I've been working on an Xamarin Forms app which displays a user Id photo that is grabbed from a Restful service, using a post method with two parameters (eventId, linkid). I have set up a method that connects to the service and grabs the httpresponse message and then converts it into a byte array. This byte array is then converted into a memory stream and placed as the image source. However I am not getting anything showing up, even though I am getting a byte array. Here is my code:-

public Byte[] GrabPhoto(ScanResult[] result) {
    //post method
    string url = @"https://xxxxxx/xxxxx/Photo";
    var values = new Dictionary<string, string>();
    values.Add ("Event", eventName);
    string link = result [0].LinkId.ToString ();
    values.Add ("LinkId", link);
    var content = new FormUrlEncodedContent(values);
    var client = new HttpClient();
    var httpResponse = client.PostAsync (url, content);
    httpResponse.Wait();
    Byte[] results = httpResponse.Result.Content.ReadAsByteArrayAsync ().Result;
    return results;
}

// Profile image for ticket holder if applicable
    var idImage = new Image { Aspect = Aspect.AspectFit };
    idImage.Source = ImageSource.FromStream(() => new MemoryStream(GrabPhoto (test)));
    idImage.HorizontalOptions = LayoutOptions.Center;

// Added to gridView        
grid.Children.Add (idImage, 0, 0);

Any help would be greatly appeciated.

Show page for few seconds and navigate to another page

$
0
0

Hi,

Is there any way to show page A for 5 seconds and navigate to page B ? I am building a POS application. It has to show approved transaction screen for few seconds and navigate to print receipt screen automatically after 5 seconds. Thanks in advance.

"Method 'CGRect..ctor' not found" exception after upgrading to Xamarin Forms version 2.2.0.43

$
0
0

The exception is thrown when this line is executed: "return base.FinishedLaunching(app, options);"

Stacktrace:

at (wrapper managed-to-native) ObjCRuntime.Messaging:IntPtr_objc_msgSendSuper (intptr,intptr)
at UIKit.UIViewController.get_View () [0x00030] in /Users/builder/data/lanes/3234/d8bedd03/source/maccore/src/build/ios/native/UIKit/UIViewController.g.cs:2783
at Xamarin.Forms.Platform.iOS.NavigationRenderer.get_NativeView () [0x00000] in :0
at Xamarin.Forms.Platform.iOS.NavigationRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00023] in :0
at Xamarin.Forms.Platform.iOS.Platform.CreateRenderer (Xamarin.Forms.VisualElement element) [0x0001b] in :0
at Xamarin.Forms.Platform.iOS.Platform.AddChild (Xamarin.Forms.VisualElement view) [0x00027] in :0
at Xamarin.Forms.Platform.iOS.Platform.WillAppear () [0x00043] in :0
at Xamarin.Forms.Platform.iOS.PlatformRenderer.ViewWillAppear (Boolean animated) [0x00016] in :0
at (wrapper managed-to-native) ObjCRuntime.Messaging:void_objc_msgSend (intptr,intptr)
at UIKit.UIWindow.MakeKeyAndVisible () [0x00010] in /Users/builder/data/lanes/3234/d8bedd03/source/maccore/src/build/ios/native/UIKit/UIWindow.g.cs:250
at Xamarin.Forms.Platform.iOS.FormsApplicationDelegate.SetMainPage () [0x00006] in :0
at Xamarin.Forms.Platform.iOS.FormsApplicationDelegate.FinishedLaunching (UIKit.UIApplication uiApplication, Foundation.NSDictionary launchOptions) [0x00028] in :0
at mCIS.iOS.AppDelegate.FinishedLaunching (UIKit.UIApplication app, Foundation.NSDictionary options) [0x00024] in /Users/xxxx/Projects/zzzzz/iOS/AppDelegate.cs:17
at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, IntPtr principal, IntPtr delegate) [0x00005] in /Users/builder/data/lanes/3234/d8bedd03/source/maccore/src/UIKit/UIApplication.cs:77
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Users/builder/data/lanes/3234/d8bedd03/source/maccore/src/UIKit/UIApplication.cs:61
at zzzzz.iOS.Application.Main (System.String[] args) [0x00008] in /Users/xxxx/Projects/zzzzz/iOS/Main.cs:17

The app worked fine (in the simulator) before upgrading.

So I'm obviously wondering how this can be fixed, if at all.

If it is a bug in said version when will a fix be released?

Can't we directly use add ControlTemplate in element style?

$
0
0

Like this:

<Label>
    <Label.Style>
               <Setter Property="ControlTemplate">
                       <ControlTemplate >
                                  <Label Text="{Binding No}" HorizontalOptions="Fill"/>
                                  <Label Text="." HorizontalOptions="Fill"/>
                       </ControlTemplate>
               </Setter>
     </Label.Style>
</Label>

It will throw :An item with the same key has already been added. Key: Xamarin.Forms.Xaml.XmlName

Binding time intervals to line color

$
0
0

Hi all,
I need to implement one particular requirement in my app which is described as below.
1. There will be line and its initial value will be 0 and final value will be 24.(24 hrs of the day)
2. As any employee leaves a company for any reason and come back after some time in a day, my app will have out time and in time for that employee wrt date.
3.Employees can leave company for any number of times in a day.
4. I need to show this on that line for example- out time is 10 am and in time is 11.30 am then there will red portion of line from value 10 to 11.30 and remaining line will be green.

How can I implement this phenomenon and which controls should i used?

Thanks in advanced.

ListView Crashing when reloading with my custom cell

$
0
0

I posted this on Stack Overflow with no luck, so excuse the cross-post.

I have an app with a Xamarin forms listview that's fed by an ObservableCollection to list user games I fetch from my server. The first time I load it up it works just fine. If I modify that existing ObservableCollection in any way my app crashes with a NullException. I've narrowed it down to my custom ViewCell (GameCell) and I've posted that below. If I comment one line out toward the bottom:

this.SetBinding(IsEnabledProperty, "Enabled");

Then it no longer crashes updating the ObservableCollection, but then I no longer get the functionality to have some cells enabled and some cells disabled. I'm guessing it's trying to set the isEnabled property to a cell that no longer exists because it's been removed on my reload. Any ideas how do this with out crashing? BTW, this works fine on Android, just not on iOS

using System;
using Xamarin.Forms;
using FFImageLoading.Forms;

namespace Upwords
{
    public class GameCell : ViewCell
    {
        public GameCell ()
        {

            var icon = new CachedImage () {
                Aspect = Aspect.AspectFit,
                HorizontalOptions = LayoutOptions.Fill,
                VerticalOptions = LayoutOptions.Fill,
                BackgroundColor = AppStyle.IconColor,
                IsVisible = false,
            };
            icon.SetBinding (CachedImage.SourceProperty, "Icon");
            icon.SetBinding (CachedImage.LoadingPlaceholderProperty, "IconPlaceholder");
            icon.SetBinding (CachedImage.ErrorPlaceholderProperty, "IconPlaceholder");

            icon.SetBinding (CachedImage.WidthRequestProperty, "Height");
            icon.SetBinding (CachedImage.HeightRequestProperty, "Height");
            icon.Success += (object sender, CachedImageEvents.SuccessEventArgs e) => {
                icon.FadeAnimationEnabled = false;
                if(icon.Source.GetType() == typeof(Xamarin.Forms.UriImageSource)) {
                    icon.BackgroundColor = Color.Transparent;
                }
            };

            icon.PropertyChanged += (object sender, System.ComponentModel.PropertyChangedEventArgs e) => {

                if(icon.Source != null)
                    icon.IsVisible = true;
                else
                    icon.IsVisible = false;

            };

            var nameLabel = new Label () {
                FontFamily = "Helvetica",
                FontAttributes = FontAttributes.Bold,
                FontSize = Device.GetNamedSize (NamedSize.Medium, typeof(Label)),
                TextColor = Color.Black,
            };
            nameLabel.SetBinding (Label.TextProperty, "Name");

            //Hide label if it's blank
            nameLabel.PropertyChanged += (object sender, System.ComponentModel.PropertyChangedEventArgs e) => {
                if(nameLabel.Text == "")
                    nameLabel.IsVisible = false;
                else
                    nameLabel.IsVisible = true;
            };

            var detailsLabel = new Label () {
                FontFamily = "Helvetica",
                FontSize = Device.GetNamedSize (NamedSize.Small, typeof(Label)),
                FontAttributes = FontAttributes.Bold,
                TextColor = Color.FromHex ("#666"),
                IsVisible = false,

            };
            detailsLabel.SetBinding (Label.TextProperty, "Details");

            //Hide label if it's blank
            detailsLabel.PropertyChanged += (object sender, System.ComponentModel.PropertyChangedEventArgs e) => {
                if(string.IsNullOrEmpty( detailsLabel.Text ) )
                    detailsLabel.IsVisible = false;
                else
                    detailsLabel.IsVisible = true;
            };

            var textLayout = new StackLayout {
                Padding = new Thickness (5, 0, 0, 0),
                Spacing = 0,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions = LayoutOptions.CenterAndExpand,
                Children = { nameLabel, detailsLabel}
            };

            var optionSwitch = new Switch() {
                HorizontalOptions = LayoutOptions.End,
                VerticalOptions = LayoutOptions.Center,
                IsVisible = false,
            };
            optionSwitch.SetBinding (Switch.IsVisibleProperty, "IsSwitch");

            var statusLayout = new StackLayout {
                Padding = new Thickness (10, 10, 10, 10),
                Orientation = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Children = { icon, textLayout, optionSwitch}
            };
            statusLayout.SetBinding (StackLayout.HeightRequestProperty, "Height");

            var separatorBox = new BoxView {
                HeightRequest = 1,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                BackgroundColor = Color.FromRgb(.75,.75,.75),
            };
            separatorBox.SetBinding (BoxView.HeightRequestProperty, "SeparatorHeight");

            var separatorBoxLayout = new StackLayout {
                Padding = new Thickness (50, 0, 0, 0),
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Children = { separatorBox }
            };

            var cellLayout = new StackLayout {
                Spacing = 0,
                Padding = new Thickness (0, 0, 0, 0),
                Orientation = StackOrientation.Vertical,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                BackgroundColor = Color.White,
                Opacity = 1.0,
                Children = { statusLayout, separatorBoxLayout }
            };
            cellLayout.SetBinding (StackLayout.OpacityProperty, "Opacity");

            var headerFrame = new ListViewLabel () {

            };
            headerFrame.SetBinding (ListViewLabel.IsVisibleProperty, "IsLabel");
            headerFrame.SetBinding (ListViewLabel.TextProperty, "Name");
            headerFrame.SetBinding (ListViewLabel.HeightRequestProperty, "Height");

            headerFrame.PropertyChanged += (object sender, System.ComponentModel.PropertyChangedEventArgs e) => {
                if(headerFrame.IsVisible)
                    cellLayout.IsVisible = false;
                else
                    cellLayout.IsVisible = true;
            };

            var paddedLayout = new StackLayout {
                Spacing = 0,
                Orientation = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions = LayoutOptions.FillAndExpand,
                Children = { headerFrame, cellLayout  }
            };

            this.SetBinding(IsEnabledProperty, "Enabled");
            this.View = paddedLayout;

        }

    }

    public class GameCellData
    {

        public string Icon { get; set; }

        public string IconPlaceholder { get; set; }

        public string Name { get; set; }

        public string Details { get; set; }

        public int Height { get; set; }

        public int SeparatorHeight { get; set; }

        public bool Enabled { get; set; }

        public double Opacity { get; set; }

        public bool IsLabel { get; set; }

        public bool IsSwitch { get; set; }

    }
}

Xamarin Forms Powershell failure

$
0
0

When I create a Blank App(Xamarin Forms Portable) in VisualStudio 2015 (Windows 10), I get the below error.
Xamarin.Forms.2.0.0.6482 : Failed to initialize the PowerShell host. If your PowerShell execution policy setting is set to AllSigned, open the Package Manager Console to initialize the host first.

I have
1) run the following command in Powershell and relaunched devenv.exe
Set-ExecutionPolicy AllSigned
2) devenv.exe run as administrator

But no luck.


How to use the control defined in another assembly, by XAML?

$
0
0

I tried to use the custom control by XAML. For example:

<?xml version="1.0" encoding="UTF-8" ?>
<ContentPage
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:customs="clr-namespace:Customs;assembly=Customs"
    x:Class="FormsCustomControl.MainPage">
    <ContentPage.Content>
        <customs:CustomControl />
    </ContentPage.Content>
</ContentPage>

But the app threw a System.IO.FileNotFoundException with this messages.

image

On the other hand, the error no longer occurs when i add somewhere the c# code that refers to my Customs assembly. For example:

using Xamarin.Forms;

namespace FormsCustomControl
{   
    public partial class MainPage : ContentPage
    {   
        public MainPage ()
        {
            new Customs.CustomControl();

            InitializeComponent ();
        }
    }
}

How can I do to so that you can use a custom control using only XAML?

Problem with Slider inside CarrouselPage

$
0
0

Hello,

I have a Slider inside a CarouselPage.

I'm having an issue, more on iOS, that I cant slide it properly.

Every time I try to slide the slider, if I don't hit the very little center of the circle in Slider it gets the "Scroll Event" of the CarouselPage and Scrolls the page itself.

I tried to increase the area of Slider with a Custom Renderer like this:

    public class CustomSliderRenderer : SliderRenderer
    {
        public override bool PointInside(CoreGraphics.CGPoint point, UIEvent uievent)
        {
            var margin = -10f;
            var area = this.Bounds;
            var expandedArea = area.Inset(margin, margin);
            return expandedArea.Contains(point);
        }
    }

But this did not worked, even with margin = 10000f the CarouselPage touch has priority.

Is there any way to workaround this?

Or some way to disable the CarouselPage scroll in some section of screen?

How to Set Plateform Specific Padding Value?

$
0
0

I want to set platform specific padding value, so I made setter like this:

    <Setter Property="Padding">
        <Setter.Value>
            <OnPlatform x:TypeArguments="x:Double" 
                Android="10, 0, 10, 0"
                WinPhone="10, 0, 10, 0"
                iOS="10, 20, 10, 0"
            />
        </Setter.Value>
    </Setter>

But I got exception "Input string was not in a correct format".

Please let me know about this reason.
Thanks

Keyboard entry pushes ListView item off the screen - help

$
0
0

Have an issue in my chat window, similar to what Nish demonstrated in DataTemplateSelector article, here I'm using forked copy of his code to
explain the issue:

I've added < ScrollView > arround < RelativeLayout > to prevent the keyboard from overlapping the entry box,

 <ScrollView>   
  <RelativeLayout>
  <ListView x:Name="MessagesListView" 
            ItemTemplate="{StaticResource MessageTemplateSelector}" 
            ItemsSource="{Binding Messages}"
            HasUnevenRows="True" 
            ItemSelected="MyListView_OnItemSelected"
            ItemTapped="MyListView_OnItemTapped"
            SeparatorVisibility="None"
            RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent,Property=Height,Factor=1,Constant=0}">
   </ListView>
    <Grid x:Name="MessageControls" RowSpacing="1" ColumnSpacing="2" Padding="5"
          BackgroundColor="#EFEFF4"
          VerticalOptions="FillAndExpand"
          HorizontalOptions="FillAndExpand"
          RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToView, ElementName=MessagesListView, Property=Height,Factor=.91,Constant=0}"
          RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent,Property=Width,Factor=1,Constant=0}"
          RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToView, ElementName=MessagesListView, Property=Height,Factor=.09,Constant=0}">
      <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*"></ColumnDefinition>
        <ColumnDefinition Width="Auto"></ColumnDefinition>
      </Grid.ColumnDefinitions>
      <Entry Grid.Column="0" HeightRequest="25" Placeholder="Message" Text="{Binding OutGoingText}"></Entry>
      <Button Grid.Column="1" Text="Send" Command="{Binding SendCommand}"></Button>
    </Grid>

  </RelativeLayout>
</ScrollView>

So now you can see the entry box, but when there is only one entry in the ListView, the keyboard pushes it off the
screen and not able to see what are you responding to:

No problem when the last item is past the 1/2 of the screen:

link to my copy of the code

Does Expandable ListView exist for XF?

$
0
0

Hi,

Is there any way to implement Expandable listview in XF(PCL)? I Mean if we click a button on a listview it should expand and show a grid/stack? Plz Suggest me ....

Expandable listview in xamarin form shared project

$
0
0

How can implement expandable listview in xamarin form shared project. Is there any control in xamarin or do we need to make a custom control?

OnAppearing still not firing after ModalPop in Droid applications (sample included)

$
0
0

XF Droid and iOS applications continue have differently behaviors when a top layer modal pops. The underneath page correctly fires its OnAppearing method in iOS, but the method is not triggered on the modal pop in Droid.

This issue was reported as fixed in forms version 2.2 back in April, but i'm still having issues while running the latest forms version (v 2.3.0.49). I've included a very basic sample project that illustrates the discrepancy between the two platforms. The project consists of 3 content pages and a tabbedpage serving as the mainpage.

This sample project can be downloaded from here https://dl.dropboxusercontent.com/u/78374852/Poppin.zip

I'm very surprised that I'm not seeing more references to this issue as it seems that it should be affecting a large set of applications. Thanks in advance.


Xamarin Forms Facebook login issues with Azure

$
0
0

Hi,

I am stuck. I have read article after article on authenticating with Facebook from within my xamarin forms app. currently only trying to get it to work with the xamarin iOS.. I have followed the sample ToDoList Manger sample project, created a Facebook app in their portal and I believe I have entered all the correct information into Facebook and Azure. My sample app runs, but when I click login I get this error : "Not Logged In: You are not logged in. Please login and try again". Is there a definitive place for me to find the answer to this? I am just trying to get a simple IOS app running. I have Azure setup with authentication with the app id and secret. Is there a low hanging fruit approach to solving this?

Thanks!!
Steve

ZXing

$
0
0

I have a question regarding the Barcode Scanner. Does it provide any information besides the barcode? Like product info etc?

Has anyone extended the new ListDataPage (Datapage) to have loading indicator and lazy loading?

$
0
0

I'm new to forms.

Whats the best approach to add a loading indicator while the data is downloading & have lazy loading?
i.e. if there's 100 items, I want to load first 10 first, and another 10 when the user scrolls down etc..

I understand DataaPages is in preview

ScrollViewRenderer Renderer

$
0
0

Hi this is the Android renderer code it works perfect in older Xamarin Forms but in 2.0 iam getting error at line 2 "Object Reference Not to set of instance of Object"

_scrollView = (HorizontalScrollView)typeof (ScrollViewRenderer)
                .GetField ("hScrollView", BindingFlags.NonPublic | BindingFlags.Instance)
                .GetValue (this);

            _scrollView.HorizontalScrollBarEnabled = false;
            _scrollView.Touch += HScrollViewTouch;

Please guide me if someone has the solution.

Thanks

Is anyone know how to integrate OCR in xamarin forms application

$
0
0

i want to get data inside picture . I am working with xamarin forms.

Viewing all 81910 articles
Browse latest View live


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