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

How can I set text and value fields for a picker when i bind a item source to it like a list

$
0
0

How can I set text and value fields for a picker when i bind a item source to it like a list


How to use multi select picker in xamarin forms?

$
0
0

I have to use a multi select in xamairn forms. I have a solution through list view but still want to find a better solution for multi select picker

Adjusting padding within label

$
0
0

I am trying to align a sub-title style label underneath a header label but have found that the larger label has padding applied to the label itself and have not found a way of removing this.

I have also tried setting the header labels YAling and VerticalOption to End and the SubTitle to Start but I still cannot get them in to reasonable proportions. Below is a screenshot and the XAML.

As you can see the padding is within the label control and the Y and Vertical options are not applying.


        <Label Text="{Binding GeneralEngineDescription}" Style="{x:Static styles:AppStyles.SmallInfoText}" VerticalOptions="Start"
        BackgroundColor="Purple" YAlign="Start" />
        </StackLayout>

Any ideas or tips to resolve this would be greatly appreciated.

Note: Only testing on iOS so far.

Xamarin Forms ListView performance problems and wrong items on scroll

$
0
0

Hi,

we have a very big problem with the ListViews in our app.

I'm showing ListViews with custom ViewCells.
I'm showing images in the custom ViewCells and render it on Android.
I trigger a redraw of my images every time the binding context of a view cell changed.

My problem if I have two different items to add to my ListView:
Item A and Item B
Both have different label and images.

Example:
I will add A as my first Item.
And then I will add B thirty times.

Only 8 items can be shown at my screen at the same time.
So I have to scroll to see all my items.

If I scroll down the first time:
Every eleventh item the image of item A is shown instead of the correct image from item B.

If I scroll up and down multiple times:
The items which are drawn wrong are changing (so items which were drawn wrong are correct; and items which were drawn correct are wrong)
The gap of 10 correct items is still there - but not always.

The text is always correct.

Any help appreciated

Thank you in advance

Best Regards

How to create a shortcut after building my app?

$
0
0

I have a question about creating a shortcut on my phone after I built my app successfully. Do anybody know about this?

Many thanks for any advices

why do App.Current.Properties not work on WUP?

$
0
0

It is running on android on ios like it should but on WUP the list App.Current.Properties is empty all the time.

Scrolling in HorizontalScrollLayout

$
0
0

Hi,
I used mcpNetwork.Components for have a Horizontal scroll layout in xamrin.form how to control scroll in this component
i want to when select a record in Horizontal Scroll Layout as an item show in scroll thumb or scroll detector how can mange and show scroll thumb when touched it with programically for example access to this Method

public Task ScrollToAsync (double x, double y, bool animated)

source code : https://components.xamarin.com/view/hscroll

var dataHScroll2 = new HScrollViewCell2Data[] {
     new HScrollViewCell2Data { id = 18, name = "Item 18", resetSelection = false, icon = "icon8.png"},
                new HScrollViewCell2Data { id = 19, name = "Item 19", resetSelection = false, icon = "icon9.png"},
                new HScrollViewCell2Data { id = 20, name = "Item 20", resetSelection = false, icon = "icon0.png"}
            };
            this.hscroll2 = new HorizontalScrollLayout
            {
                ItemSource = dataHScroll2,
                ItemTemplate = new DataTemplate(typeof(HScrollViewCell2)),
                HeightRequest = 60,
                SelectionBackGroundColor = Color.Lime,
                MultiSelection = true
            };
            this.hscroll2.ItemSelected += hscroll1And2_ItemSelected;
       async void hscroll1And2_ItemSelected(object sender, HScrollEventArgs e)
        {
            HorizontalScrollLayout layout = (HorizontalScrollLayout)sender;
            if (layout.Id.ToString() == this.hscroll1.Id.ToString())
            {
                HScrollViewCell1Data record = (HScrollViewCell1Data)e.Data;
                if (record.shortSelectionTime)
                {
                    await Task.Delay(250);
                    layout.UnselectItem(record);
                }
            }

            if (layout.Id.ToString() == this.hscroll2.Id.ToString())
            {
                HScrollViewCell2Data record = (HScrollViewCell2Data)e.Data;
                if (record.resetSelection)
                {
                    await Task.Delay(250);
                    foreach (object selectedRecord in layout.SelectedItems)
                    {
                        layout.UnselectItem(selectedRecord);
                    }
                }
            }

        }

Thanks

Hide the MasterPage menu on init (UWP only)

$
0
0

Hi you all,

I have managed to get my Masterpage/detail working nice and it seems that on Android I don't have to change anything to get what IU want but my issue is this on Windows UWP:

When the app is initiated the menu shows. I want it to be hidden. I have tried setting IsPresented="False" on the MasterPageItem without succes.

Thanks for your help!


Understanding XAML binding

$
0
0

I seem to be missing something in my understanding of XAML binding and I was hoping someone could point me in the right direction. I want to create a tabbed navigation view of a complex object. My thought was to retrieve the object once and then have each page bind to that instance and show the portions that are relevant to the tab.

I created a BindableProperty and I'm using the GetValue and SetValue on the TabbedPage and and followed the same pattern on each of the ContentPage tabs.

In the XAML for the TabbedPage the MyObject="{Binding MyObject}" doesn't seem to do anything. The setter of the MyObject property on the tab pages is never triggered. I tried explicitly setting BindingContext="{Binding MyObject}" of the TabbedPage, and then setting the Binding to MyObject="{Binding .}", but it still didn't set the property of the tab pages.

I looked at an MVVM pattern but all that adds is property change events to the MyObject class and the properties won't change after retrieval. A refresh would be update the entire MyObject instance, as opposed to individual properties.

I can absolutely set the tab properties pragmatically, I was just wondering what I'm doing wrong in the context of data binding.

namespace MyApp.Pages
{
    public partial class MyObjectPage : TabbedPage
    {
        public static readonly BindableProperty MyObjectProperty = BindableProperty.Create<MyObjectPage, MyObject>(
            p => p.MyObject,
            null,
            BindingMode.OneWay,
            propertyChanged: MyObjectChanged);

        public MyObject MyObject
        {
            get { return (MyObject)GetValue (MyObjectProperty); }
            set { SetValue (MyObjectProperty, value); }
        }

        private int ObjectId;

        public MyObjectPage (int objectId)
        {
            ObjectId = objectId;
            InitializeComponent ();
        }

        public async Task SetMyObject()
        {
            MyObject = await MyObjectService.GetObject (ObjectId);
        }

        protected async override void OnAppearing ()
        {
            base.OnAppearing ();
            await SetMyObject ();
        }

        private static void MyObjectChanged(BindableObject bindable, MyObject oldValue, MyObject newValue)
        {

        }

    }
}

<?xml version="1.0" encoding="UTF-8"?>
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:pages="clr-namespace:MyApp.Pages;assembly=MyApp"
             x:Class="MyApp.Pages.MyObjectPage" >
    <TabbedPage.Children>
        <pages:MyObjectMainTab
            x:Name="MainTab"
            Title="Detail"
            MyObject="{Binding MyObject}" />
        <pages:MyObjectContactTab
            x:Name="ContactsTab"
            Title="Contacts"
            MyObject="{Binding MyObject}" />
    </TabbedPage.Children>
</TabbedPage>

Xamarin.Forms + VS 2015

$
0
0

Sorry if my english is not good.

I started to use Xamarin in Visual Studio 2015 and faced with problem. When im creating Xamarin.Forms project i have a message that i have error with subproject creating "WinPhone". I must update VS to solve this. But i have a latest version and i cant find how i can uptade this like that saying:"Click right button on the project and choose "Dowloand uptade" ". I updated to the "VS 2015 update 1" again but still have this problem. Please help.

How to detect SSID of a wifi connection in Xamarin.Forms

$
0
0

I would like to get the SSID from a router via. wifi

I have searched the web but couldn't find anything usefull :-( If I look in the documentation there is a Android.Net.Wifi.WifiInfo.SSID Property but the property is missing in both my Xamarin.Forms project and in a Xamarin.Android demo project I have made.

I have also tried the Connectivity Plugin for Xamarin.Forms, James Montemagno have made, but the SSID is not avaible in this plugin.

Any help would be great

How do I show security image overlay when app is running in background?

$
0
0

Hi,

What I want to do is

  1. Open app
  2. Do some actions
  3. Click on Home button
  4. App will be running in background
  5. User clicked the recent apps button in android (in iOS, click home button twice )
  6. Display list of apps running in background

in 6th point I need to show an image overlay for my app instead of showing a view which user was working before app being sent to background.
Please see the attachment for more understanding.

Thanks
Vinod

Windows Universal App & Xamarin.Forms - Crash when image change

$
0
0

Hello,
Does someone know any workaround for this issue ?

Mobile Ads OTHER than Admob?

$
0
0

Hi.
I'm sick of Admob.
I'm looking for OTHER ads for Xamarin.
Looking for Xamarin Forms but can be also for Xamarin.IOS and Xamarin.Android via custom renderer (prefer also for WinPhone8.1 WinRT).
Anyone?

Image disappears in AbsoluteLayout

$
0
0

Hi there,

I am having a little difficulty trying to get an image to fill the full width of its parent, retain its aspect ratio and determine the height from its width in xaml.
The code I have seems to do what I need but the image disappears and leaves the perfect amount of space for the image.

`

<Label FormattedText="{Binding FormattedQuestionText}"/>

<AbsoluteLayout IsVisible="{Binding HasImage}" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Padding="0, 20">
    <Image
         Source="{Binding ImageSource}"
         Aspect="AspectFit"
         AbsoluteLayout.LayoutBounds="0.5, 0.5, 1, AutoSize"
         AbsoluteLayout.LayoutFlags="SizeProportional"/>
    <Label Text="&#xf065;"
           AbsoluteLayout.LayoutBounds="0.5, 0.5, 1, 1"
           AbsoluteLayout.LayoutFlags="All"
           FontSize="Medium"
           TextColor="#0083C7"
           FontAttributes="Bold"
           FontFamily="FontAwesome"/>
  </AbsoluteLayout>

`

Am I doing something silly?

Kind Regards

Brian


Announcing FreshMvvm 1.0.1 Release

$
0
0

Announcing FreshMvvm 1.0.1 Release.

No bugs to fix, Yay! Actually I did some changes that might work better for UWP projects.

Only some awesome new features, actually really nice extended and very useful features. With such a big take up of FreshMvvm we’ve ramped up the development. As always we take feedback and iterate on it so let us know of anything.

@ThomasBurkhart and @GeraldVersluis you might like to know about this... :)

http://www.michaelridland.com/xamarin/announcing-freshmvvm-1-0-1-release/

Set ButtonType in ButtonRenderer - iOS specific

$
0
0

Hello everyone,

I'm currently trying to implement customs controls (Buttons, Labels, etc.) which looks and behave on all plattform similar.
I startet with Android and a custom button, which works fine. Now I'm trying to implement the same on iOS and I have one issue.

The button should be green with white text and on click the button should be in a darker green, but same text color.

I tried to implement on iOS the following ButtonRenderer:

class OBButtonRenderer : ButtonRenderer
{
    protected override void OnElementChanged(ElementChangedEventArgs<Button> e)
    {
        base.OnElementChanged(e);

        if (Control != null)
        {
            Control.SetBackgroundImage(ImageWithColor(Color.Green), UIControlState.Normal);
            Control.SetBackgroundImage(ImageWithColor(Color.Lime), UIControlState.Highlighted);
        }
    }

    private UIImage ImageWithColor(Color color)
    {
        var rect = new RectangleF(0, 0, 1, 1);

        UIGraphics.BeginImageContext(rect.Size);

        var context = UIGraphics.GetCurrentContext();
        context.SetFillColorWithColor(color.ToCGColor());
        context.FillRect(rect);

        var image = UIGraphics.GetImageFromCurrentImageContext();
        UIGraphics.EndImageContext();

        return image;
    }
}

Now I have the issue that the Highlighted image is on top of the normal image, so that the button is not in Lime, more in something between and the text is getting green.

I tried to implement a iOS only Xamarin App and if I set the ButtonType to Custom, then it works. But how can I set the ButtonType in the Renderer?

Thanks for the help.

kind regards

Martin

TabbedPage ItemTemplate definition in XAML

$
0
0

I'd like to define the ItemTemplate of a TabbedPage in XAML, is is possible? tried several definitions but can't find a working one.
Hints?

System.InvalidCastException: Object must implement IConvertible - Xamarin Footer iOS

$
0
0

I'm having this exception every time I try to set a footer on ios:

System.InvalidCastException: Object must implement IConvertible.
  at System.Convert.ChangeType (System.Object value, System.Type conversionType, IFormatProvider provider) [0x0005a] in /Users/builder/data/lanes/2377/73229919/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/mscorlib/system/convert.cs:343
  at Xamarin.Forms.BindingExpression.TryConvert (Xamarin.Forms.BindingExpressionPart part, System.Object& value, System.Type convertTo, Boolean toTarget) [0x00034] in <filename unknown>:0

when I call:

listView.Footer = foot;

Where foot is from type:

public class Model_Footer
    {
        public int pt1 { get; set; }
        public string pt2 { get; set; }
        public double pt3 { get; set; }
        public double pt4 { get; set; }

        public Model_Footer ()
        {
        }
    }

This exception do not crash the app, but the footer do not work as expected.

My footer template is from a type that implements a contentView:

footerTemplate = new DataTemplate (typeof(FooterCell));
listView.FooterTemplate = footerTemplate;

public class FooterCell : ContentView

if I understand right the footer functionality the listview.Footet should be the binding context for listview.FooterTemplate...
And it works as expected in Android.

Anyone can give a help?

Socket IO

$
0
0

Hi,

Does anyone have Socket IO working with Xamarin.Forms? I've tried the component too but it installs with no luck.

Thanks

Viewing all 58056 articles
Browse latest View live


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