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

Can not build Xamarin's ModernHttp version.

$
0
0

Hi,

I noticed ModernHttp is not being updated long time,
After search some, I noticed there is Xamarin updated version.

here.
https://github.com/xamarin/ModernHttpClient

I want to try this.
But I couldn't find it on nuGet Gallery nor build library to my own.
It gives error "obsolete api" when I try build android library.
Can't understand because I set API level as library use.

Any tip please?


No TLS 1.2 support in Xamarin.Forms? Android app cannot connect to TLS 1.2 web sites

$
0
0

Mono now has TLS 1.2 support: http://tirania.org/blog/archive/2016/Sep-30.html
According to this post on stackoverflow it should work on Xamarin:

http://stackoverflow.com/questions/40735964/how-can-i-enable-ntlm-and-tls-1-2-with-xamarin-on-android

Yet in my Xamarin.Forms (Android version) I cannot connect to TLS 1.2 web sites to download an image:

https://randomuser.me/api/portraits/med/men/85.jpg

This is the error I get:

Image Loading: Error getting stream for randomuser.me/api/portraits/med/men/85.jpg: System.Net.WebException: Error: SecureChannelFailure (The authentication or decryption has failed.) ---> System.IO.IOException: The authentication or decryption has failed. ---> System.IO.IOException: The authentication or decryption has failed. ---> Mono.Security.Protocol.Tls.TlsException: The authentication or decryption has failed. –

Why?

How could I solve the AdjustResize bug after Xamarin Forms update 2.3.3.168

$
0
0

Just in Android Platform, before Xamarin Forms update, we were using the AndroidBug5497WorkaroundForXamarinAndroid code to fix it, but in the Xamarin Forms 2.3.3.168 update and all following versions this fixed no longer works fine, causing an extra scroll out of screen bounderies, leaving a white space between the bottom of the view and the soft-keyboard without any scrolling option to get the view right.

We use that code referenced by this link in xamarin forums and this sample code that works fine using Xamarin Forms 2.2.0.45, but when is updated to 2.3.3.168 or a recent one, is replicated the shown error.
Next is the error sample image.

Could you please help us with any solution for this?

What is the best way to format text in Xamarin.Forms?

$
0
0

I am converting a website into an app. This is what one of the website's pages looks like: http://www.anesthesiaconsiderations.com/#!airway-fire/c1gxc

This is what my code looks like:

using System;
using Xamarin.Forms;

namespace FormsGallery
{
class AirwayFire : ContentPage
{
public AirwayFire()
{
Label header = new Label
{
Text = "Airway Fire",
FontSize = 50,
FontAttributes = FontAttributes.Bold,
HorizontalOptions = LayoutOptions.Center
};

        ScrollView scrollView = new ScrollView
        {
            VerticalOptions = LayoutOptions.FillAndExpand,
            Content = new Label
            {
                Text = "Management\n\n" +

"Inform team & call for help" +
"Simultaneously remove the endotracheal tube (ETT) & stop gases/disconnect circuit" +
"Pour saline or water into airway" +
"Remove airway foreign bodies (ie: ETT pieces, sponges)" +
"When fire is extinguished: re-establish ventilation; avoid supplemental oxygen if possible" +
"Consider prompt reintubation prior to swelling & coordinated with bronchoscopy" +
"Examine entire airway (including bronchoscopy) to assess injury & remove residual debris" +

"Prevention\n\n" +

"For high risk procedures:\n" +
"Discuss fire prevention & management with team during time-out" +
"Avoid FiO2 > 0.3 & avoid N2O" +

"For laser surgery of vocal cord or larynx:\n" +
"Use laser resistant ETT (single or double cuff)" +
"Assure ETT cuff sufficiently deep below vocal cords" +
"Fill proximal ETT cuff with methylene blue-tinted saline (acts as a marker if cuff perforated by laser)" +
"Ensure laser in STANDBY when not in active use" +
"Surgeon protects ETT cuff with wet gauze" +
"Surgeon confirms FiO2 < 0.3 & no N2O prior to laser use (may require several minutes to dilute FiO2 & FeO2 to <0.3 depending on fresh gas flow & initial FiO2)" +

"For non-laser surgery in oropharynx:\n" +
"Regular PVC ETT may be used" +
"Consider packing wet gauze around ETT to minimize O2 leakage" +
"Consider continuous suctioning of the operating field inside oropharynx",

                FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)),
            }
        };



        // Build the page.
        this.Content = new StackLayout
        {
            Children =
            {
                header,
                scrollView,
            }
        };
    }
}

}

This text looks really unformatted. How do I add bullet points, indents, and other features? Should I use XAML or just plain C# code.

How to Bind a class to a UIElement

$
0
0

I have a menu that has multiple menu items. Each menu item has a title , subtitle, and a page property that needs to be bound to. But when binding to the UI control I get errors saying that binding cannot convert to MenuItem. Even when testing if I can bind a string to a bindable property it says I cannot convert binding to type string. What is going on? Am I doing this correctly?

Xaml:

`<local:MenuItemControl x:Name="scanMenuItem" Item="{Binding scanItem}"></local:MenuItemControl>`
`<local:MenuItemControl x:Name="factoryMenuItem" Item="{Binding factoryItem}"></local:MenuItemControl>`

Code Behind:

public partial class Home : ContentPage
    {
        public string s { get; set; }
        public MenuItem scanItem;
        public MenuItem factoryItem;
        public Home()
        {
            InitializeComponent();
            scanItem = new MenuItem("Scan", "", new Scan());
            factoryItem = new MenuItem("Factory", "", new FactoryPage());

            NavigationPage.SetHasNavigationBar(this, true);

            Title = "Home";
        }
    }

MenuItem custom UI control:

public class MenuItemControl : ContentView
    {
        public static BindableProperty item = BindableProperty.Create("Item", typeof(MenuItem), typeof(MenuItemControl), null,  BindingMode.TwoWay);

        public MenuItem Item
        {
            get
            {
                return (MenuItem)GetValue(item);
            }
            set
            {
                SetValue(item, value);
            }
        }
        public MenuItemControl()
        {
            if (Item == null){
                Item = new MenuItem("", "", null);
            }

            BoxView line = new BoxView
            {
                HeightRequest = 1,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                BackgroundColor = Color.FromHex("#f1f1f1")
            };

            Label title = new Label
            {
                Text = Item.title,
                Margin = new Thickness(10, 2, 0, 0),
                HorizontalOptions = LayoutOptions.StartAndExpand,
            };

            Label subTitle = new Label
            {
                Text = Item.subtitle,
                Margin = new Thickness(10, 2, 10, 0),
                FontSize = 14,
                TextColor = Color.FromHex("#c1c1c1"),
                HorizontalOptions = LayoutOptions.End,
            };

            Image image = new Image
            {
                HorizontalOptions = LayoutOptions.End,
                Source = "icons/blue/next",
                WidthRequest = 20
            };

            new StackLayout
            {
                Children = {

                    line,
                    new StackLayout{
                        Orientation = StackOrientation.Horizontal,
                        HorizontalOptions = LayoutOptions.Fill,
                        Padding = new Thickness(10),
                        Children ={

                            title,
                            subTitle,
                            image
                        }
                    }
                }
            };
        }

How to populate previous page after selecting an item in a listview

$
0
0

I'm in a position where I can select an item in a listview, a SelectedItemChangedEvent is fired and in the code behind of the page I can handle this to get the item object ready to use. However, I need to use the data in this item on the previous page on the Navigation stack, but I cannot pass in an object when using Navigation.PopAsync().

Any ideas on how I can achieve this?

Thanks

What is the purpose of using Bindable Property over getters and setters?

$
0
0

What is the purpose of using Bindable Properties over getters and setters in a Xamarin forms project? It seems everything that bindable properties do, public getters and setters can do as well.

Cross Platform Crop Image View

$
0
0

Hey,

Anyone have ever implemented some custom crop image UI that can be used in forms ios/android/win phone?
What I`m trying to achieve is something like instagram that crop a image to a square, so I can store in a db and show it in a circle image after to give my app a better design.
Someone have anything like this? So I will not start from scratch...

Thanks


Connect mobile application to SQL server

$
0
0

Hello everyone,

I am new in developing mobile applications. I am trying to start a simple project on Android/iOS/Windows phones. The application should contain a login page that the user enters username and password and the application should check these info on the local SQL server and check whether the user is registered or not. I have couple of questions and just need your help :)

1) How to create the server tasks (PHP, Json...etc) and what should the server send to the application?
2) How to connect the xamarin.form project to that SQL server to check the info the user entered?

your help will be really appreciated :)
Thank you in advance!

Can you access ListView properties from inside of a Custom View Cell?

$
0
0

I have a button inside of my Custom ViewCell that is a delete button for the cell. I want to be able to clear the selected item of the ListView if that button is clicked. How do I do that / is that possible?

List AsReadOnly

$
0
0

Hi to all, exists in Xamarin the equivalent of AsReadOnly

        public List<BankViewModel> Banks
        {
            get { return _banks.AsReadOnly(); }
        }

Thanks in advice

UrhoSharp.Forms Access Violation Exception

$
0
0

I keep encountering an exception when running my Xamarin.Forms application since using the Urho.Forms package.

An exception of type 'System.AccessViolationException' occurred in Urho.Forms.dll but was not handled in user code

Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

Stack Trace:

at Urho.Node.Node_AddComponent(IntPtr handle, IntPtr component, UInt32 id, CreateMode mode)
at Urho.Node.AddComponent(Component component, UInt32 id, CreateMode mode)
at Urho.Node.CreateComponent[T](CreateMode mode, UInt32 id)
at SavantX.StaticScene.<CreateScene>d__4.MoveNext()
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.MoveNextRunner.InvokeMoveNext(Object stateMachine)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)

Disabled button color

$
0
0

I changed background color of a button and noticed that when button is disabled (IsEnabled=False) the button is not changed at all and looks same as enabled button. Then I decided to use triggers to set disabled background color as below:

<Style TargetType="Button">
    <Setter Property="BackgroundColor" Value="{StaticResource red}" />
    <Style.Triggers>
      <Trigger TargetType="Button" Property="IsEnabled" Value="True">
        <Setter Property="BackgroundColor" Value="{StaticResource red}" />
      </Trigger>
      <Trigger TargetType="Button" Property="IsEnabled" Value="False">
        <Setter Property="BackgroundColor" Value="{StaticResource grey}" />
      </Trigger>
    </Style.Triggers>
</Style>

Now enabled button looks good, disabled button looks good, but when button is disabled and then I change it to enabled, background color is changed to default one not to one that I defined.
What's is best way to customize disabled button style?

SkiaSharp - Graphics basics

$
0
0

I am fairly new to Xamarin, Cross-platform, Forms, Graphics, etc. I see the SkiaSharp form samples. I looked at the DrawXamagon code. I modified it, to draw a polygon. Only a small part of it is shown, because my polygon is too large, (Upside down also, I think), off center, etc., etc. The sample code has predefined hard coded sizes of the sample image, display area, etc., that do not fit my polygon image.

Is there a sample anywhere that does not have hard coded values, and that is commented as it goes along. I do not care what it draws (triangle, circle, polygon, whatever). Something that besides creating the image to be displayed, that also determines the size of the display area, and, the image to be displayed, and then scales the image so that it fits, and, is centered? Is this there already in one of the samples...if so where?

How to bind button IsEnabled to checkbox in a listview

$
0
0

Hello, I have a page with a listview and a button to proceed. Inside the listview, there is a checkbox for every row. I would like to bind the button IsEnable property to the checkbox checked event when user checks the box. Could you please show me how to do that? Thanks in advance.


How do I layout my page to achieve this?

$
0
0

I can get this to work fine if I set a pixel height on my image, but I'm trying to get it to be 40% of the scrollview height, and have the text be able to expand off screen and scroll up(and image scroll out of the way and I'm having trouble with this.

The left is how it would load, and the right is how it would scroll up. The black frame is the device screen.

Thanks for the help!

App crashing on Windows Phone when deplyed in Release mode

$
0
0

Hi,

We have developed a Xamarin Forms app supporting Android, iOS and Windows Phone. The app is working on all three OS when deployed in Debug mode. It's also working on Android and iOS when deployed in Release mode. It crashes immediately after displaying Splash screen on Windows Phone 8.1/10 when deployed with Release mode but strangely all works fine when deployed using Debug mode.

Any idea from experts here?
Is there any way to get see the app log to diagnose the crash reason?

Thank you,
Deepak Sakpal

Build error when deploying to physical iOS device

$
0
0

I have a Xamarin.Forms project that work great on the iOS simulator. I have attempted to deploy to a correctly partitioned iOS device (iPhone 6s on 9.3) and I am getting the following strange error:

 /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/iOS/Xamarin.iOS.Common.targets: Error: System.IO.FileNotFoundException: /Users/tkelly/Projects/Attendance/iOS/obj/iPhone/Debug/build-iphone8.1-9.3.2/ibtool/LaunchScreen.storyboardc/01J-lp-oVM-view-Ze5-6b-2t3.nib does not exist
File name: '/Users/tkelly/Projects/Attendance/iOS/obj/iPhone/Debug/build-iphone8.1-9.3.2/ibtool/LaunchScreen.storyboardc/01J-lp-oVM-view-Ze5-6b-2t3.nib'
  at System.IO.File.Copy (System.String sourceFileName, System.String destFileName, Boolean overwrite) <0x1a24c50 + 0x00333> in <filename unknown>:0
  at Xamarin.MacDev.Tasks.SmartCopyTaskBase.CopyFile (System.String source, System.String target, System.String targetItemSpec) <0x48c2fa8 + 0x000c7> in <filename unknown>:0
  at Xamarin.MacDev.Tasks.SmartCopyTaskBase.Execute () <0x48c2770 + 0x002bf> in <filename unknown>:0  (Attendance.iOS)

Does anyone know about this error? I cannot find anything on google about this.

Thanks for any help

Change font size printing bluetooth printer

$
0
0

Hello Everyone.

I am developing a multiplatform application, this makes the impression perfectly, but I would like to know how to change the font of the letter and be able to change some words in bold.

I use the Intermec PR2 bluetooth printer.

image tap handler for custom ViewCells

$
0
0

I have a ListView with custom cells. In each custom cell, the user can tap an ellipses looking image to invoke functionality in the cell. At this point I am focused on an aesthetic issue.

Notice I have implemented this with a Button containing an image with the ellipses. I used a Button because it natively responds to tap events. The problem is the button has a border. Also, the button has a tap animation that is less than desirable.

<ListView x:Name="___listview" HasUnevenRows="True">
    <ListView.ItemTemplate>
        <DataTemplate>
            <ViewCell>
                <StackLayout Orientation="Horizontal" Padding="10" Margin="10">
                    <Button Image="{Binding ImageName}" Command="{Binding UpCount}"
                            BackgroundColor="White" WidthRequest="50" />
                    <Label Text="{Binding Count}" HorizontalOptions="CenterAndExpand" />
                </StackLayout>
            </ViewCell>
        </DataTemplate>
    </ListView.ItemTemplate>
</ListView>

Each ViewCell is bound to the following model.

public class Model : INotifyPropertyChanged
{
    public Model()
    {
        _count = 0;
        _imageName = "ellipses_vertical.png";
        UpCount = new Command(() =>
        {
            Count++;
            ImageName = (_imageName == "ellipses_vertical.png")
                                    ? "ellipses_horizontal.png"
                                    : "ellipses_vertical.png";
        });
    }

    int _count;
    public int Count
    {
        get { return _count; }
        set { if (_count != value) { _count = value; OnPropertyChanged("Count"); } }
    }

    string _imageName;
    public string ImageName
    {
        get { return _imageName; }
        set { if (_imageName != value) { _imageName = value; OnPropertyChanged("ImageName"); } }
    }

    public ICommand UpCount { get; set; }

    public event PropertyChangedEventHandler PropertyChanged;
    protected virtual void OnPropertyChanged(string propertyName)
    {
        if (PropertyChanged != null)
            PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
    }
}

I think what would work better is a simple Image in lieu of the Button. However, the Image has no native 'tap' handling or ICommand handling. Using a TapGestureRecognizer you can attach this type of behavior to other elements including an Image. The code would look something like this...

var tg= new TapGestureRecognizer();
tg.Tapped += (s, e) => {
    // handle the tap
};
image.GestureRecognizers.Add(tg);

Each ViewCell has an Image for which this Gesture Recognizer would need to attach. However, I can't reference the Image by name in my model.

Is there a way enable a tap handler for each ViewCell's image and handle the tap in the Model (not code behind)?

Viewing all 91519 articles
Browse latest View live


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