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

class BindablePicker: Picker and SelectedIndexChanged

$
0
0

Hi,
I have a BindablePicker with SelectedItem bound to a view model property "ENTRY".
This view model is initialilized from json and upon initialization I have to set SelectedIndex so that the Picker shows the current value.

I want to handle an event when user makes a selection (i.e. SelectedIndexChanged event) BUT this event fires whenever the view model is initialized.

What can I do?


How to put the grid on the bottom of the page?

$
0
0

Hi,
I am following the FormGridLayout example but I want to put the grid at the bottom of the page, how to do it? seems the VerticalOptions = LayoutOptions.End cannot help, or maybe it just work not in the stacklayout?
Thanks in advance for the help.

Here is the code I used:

` public GridLayout()
{
var layout = new StackLayout
{
Orientation = StackOrientation.Vertical,
Padding = 20

        };

        var grid = new Grid
        {
            RowSpacing = 50
        };

        grid.Children.Add(new Label { Text = "This" }, 0, 0);
        grid.Children.Add(new Label { Text = "text is" }, 1, 0);
        grid.Children.Add(new Label { Text = "3rd column" }, 2, 0);
        grid.Children.Add(new Label { Text = "in a" }, 0, 1);
        grid.Children.Add(new Label { Text = "grid" }, 1, 1);

        grid.VerticalOptions = LayoutOptions.End;

        var gridButton = new Button { Text = "Click me!" };
        gridButton.VerticalOptions = LayoutOptions.End;
        gridButton.Clicked += delegate
        {
            gridButton.Text = string.Format("Thanks! {0} clicks", count++);
        };

        layout.Children.Add(gridButton);
        layout.Children.Add(grid);
        Content = layout;
    }

`

Error While Building App: could not import CSharp.targets file

$
0
0

The error is in the file .csproj on the line:

Error: /Users/cyberinjector/Projects/test/test/test.csproj: /Users/cyberinjector/Projects/test/test/test.csproj could not import "$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" (test)

The imported project was not found confirm that the path in import....etc
How can I fix this error ?
tnx

How to set focus for dynamically created entry fields

$
0
0

Hi,

I am using the below code to display the Entry fields dynamically. on submit button click event i need to set focus if the entry field is empty.

this.grdAdditionalData.Children.Add (new Entry { Placeholder = info.LabelName}, 1, 3);

Xamarin - Customize the style of the Maps

$
0
0

Hi,

My company asked me if I would be able to design the map on some points, however, I don't think is possible but I'm not sure.

SnazzyMaps is the example taken by company

The customizations asked are: the background color, road color, filter of white when a pop-up appears, things like it ! I already have my CustomMap ad I know about custom path, custom pins, but it's not enough.

Thank !

Bug in TableView Selected Item?

$
0
0

Hi,

I'm having an issue with TableView vs. ListView. When you tap a row in a ListView, the standard behaviour is to highlight that row until another is selected. In Xamarin.Forms, this works as expected when using a ListView, but not with a TableView. With a TableView, the row is selected for a moment, but appears to be immediately deselected and the "selected" background colour fades away.

To test, I created 2 basic Forms apps and ran the Android app in each case. Here's the code:

TableView:


namespace BasicFormsApp
{
public class MyItem
{
public string ItemName { get; set; }
}

public class App : Application
{
    private readonly List<MyItem> _itemList = new List<MyItem>
    {
        new MyItem {ItemName = "Item 1"},
        new MyItem {ItemName = "Item 2"}
    };

    public App()
    {
        var tableSection = new TableSection();
        var tableRoot = new TableRoot();
        var myTable = new TableView(tableRoot);

        foreach (var item in _itemList)
        {
            var tableCell = new ViewCell
            {
                View = new Label
                {
                    Text = item.ItemName
                }
            };

            tableSection.Add(tableCell);
        }

        tableRoot.Add(tableSection);
        myTable.Root = tableRoot;

        MainPage = new ContentPage
        {
            Content = myTable
        };
    }
}

}

ListView:


namespace BasicFormsApp
{
public class MyItem
{
public string ItemName { get; set; }
}

public class App : Application
{
    private readonly List<MyItem> _itemList = new List<MyItem>
    {
        new MyItem {ItemName = "Item 1"},
        new MyItem {ItemName = "Item 2"}
    };

    public App()
    {
        MainPage = new ContentPage
        {
            Content = new ListView
            {
                ItemsSource = _itemList
            }
        };
    }
}

}

Am I doing something wrong, or is this an issue with TableView rendering in Xamarin.Forms?

Thanks,

Peter.

I can't type commas in an numeric entry binded to a decimal value

$
0
0

This is really really strange.

I have an entry binded to a ´decimal´ value with a default value (which comes from server):

    <Entry Text="{Binding AmountToPay}" Keyboard="Numeric" />

And I see the value correctly, but if I remove the value and I try to type a different value, I can't introduce a comma. For example, I can't introduce 12,25, but I can introduce 12.

Do somebody know what is happening?

How can i change bindingContext after a web service call ?

$
0
0

I'm a newbie with Xamarin and i have some troubles about binding context. I have tried OnAppearing method but content page shows myModel empty.
Is there another way to do it?

Here is my code

userProfile.xaml.cs

public partial class UserProfilePage : ContentPage
{
public UserProfilePage ()
{
InitializeComponent ();
BindingContext = myModel;
}

    protected override async void OnAppearing()
    {

        base.OnAppearing ();

        myModel = await getUserDetail ();

    }

    public async Task<myModel> getUserDetail()
    {

        //calling web service.....
    }

userProfile.xaml

Label Text="{Binding Path=name}"/>


Problem Showing Alerts on iOS.

$
0
0

I attempt to show an alert like this

App.MainPage.Navigation.NavigationStack.Last().DisplayAlert(title, message, close);

but on iOS I get the warning

2016-05-20 10:14:46.575 Voyager.iOS[4551:64851] Warning: Attempt to present <UIAlertController: 0x7a3ba000> on <Xamarin_Forms_Platform_iOS_NavigationRenderer: 0x79e58800> which is already presenting (null)

When I try to show another alert after the user has closed the first one it will now not show.

Any suggestions? I can create a custom navigation on iOS for showing alerts, but surely that should not be necessary.

Thanks,
Martin

Geolocator problem

$
0
0

Hello,
I have some problem with Geolocator plugin (tested only on Android). I cant fetch current location because of this error:

System.Threading.Tasks.TaskCanceledException: A task was canceled.

Here is my code :

private async void getLocation()
        {
            var locator = CrossGeolocator.Current;
            locator.DesiredAccuracy = 20;
            if (locator.IsGeolocationEnabled)
            {
                var current = await locator.GetPositionAsync(timeoutMilliseconds: 60000);
                int xPos = (int)current.Longitude;
                Debug.WriteLine(xPos.ToString());
            }
        }

I have all permisions added, library added.... and it stucks at line var current.... and throws this exception ;/

Xamarin Forms black screen

$
0
0

When my application is onSleep modus I get a black screen if I want to open my application back from the sleeping modus?

Can someone help me?

How To Hide/Disable Toolbar item On MasterDetailPage(On Drawer Open)?

$
0
0

Hi,

Is there a way to hide toolbar items of the detail page when Menu option is clicked in Xamarin Form MasterDetailPage?

Details-
I have a MasterDetailPage with menu option pointing to different detail pages. In each detail page I have toolbar. Now when I click on the hamburger menu icon, the menu option appears (i.e., drawer) for navigation. But, the toolbar is still visible and buttons that I have in the toolbar is clickable. I want these toolbar icons either should be hidden or disbaled when the menu appears so that user cannot perform any actions from the toolbar. I have not found any way to achieve this. Please let me know if there any way to achieve this using xamarin form?

PFA for the screenshots and a sample of the current behaviour.

Thanks & Regards,
Ravi

imageimage

What is MKOverlayWrapper? It's breaking my map renderer...

$
0
0

After updating to the Unified API, I started seeing a MKOverlayWrapper being passed into a method in my custom MapRenderer:

public override MKOverlayRenderer OverlayRenderer(MKMapView mapView, IMKOverlay overlay)

The second parameter (IMKOverlay) is now of type MKOverlayWrapper, and there is no way to cast an MKOverlayWrapper to the type of my actual overlays, MKPolyline. Anyone have an idea how to fix this?

DevExpress Unbound columns help

$
0
0

I am trying to use the DevExpress data grid control with multiple unbound columns. I am trying to fill their values using the event technique. However, the event is only firing for the first unbound column, but not my other unbound columns. Anybody have an example that shows multiple unbound columns that get their data from the event?

Crossplatform media streaming solutions in Xamarin Forms?

$
0
0

I'm currently digging around looking for a solution to get some basic video streaming working with Xamarin Forms. Has anyone had any success on this front yet? Just straightforward 'chop streaming video into pieces and send it online' action.


Object reference not set to an instance in MainActivity.cs for Theme.AppCompat.Light.NoActionBar

$
0
0

Hi,

I have a project to use Theme.AppCompat.Light.NoActionBar and make side menu to slide over the default action bar and provide the android native theme for action bar. This is similar to XamarinCRM example which is available as open source.

But the similar thing when I am trying throws "Object reference not set to an instance" in MainActivity.cs in the line LoadApplication(new App());

I think you can get better idea if you role through my application. Please let me know where should I need changes / correction.

MainActivity.cs

`using System;
using Xamarin;
using Xamarin.Forms;

using Android.App;
using Android.Content;
using Android.Content.PM;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
using ImageCircle.Forms.Plugin.Droid;
using Xamarin.Forms.Platform.Android;

namespace SideMenuPOC.Droid
{
[Activity (Label = "SideMenu POC", Icon = "@drawable/icon", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsApplicationActivity
{
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);

        global::Xamarin.Forms.Forms.Init (this, bundle);
        FormsAppCompatActivity.ToolbarResource = Resource.Layout.toolbar;
        FormsAppCompatActivity.TabLayoutResource = Resource.Layout.tabs;
        ImageCircleRenderer.Init();

        LoadApplication (new App ());
    }
}

}

`

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.companyname.sidemenupoc">
    <uses-sdk android:minSdkVersion="15" />
    <application android:label="SideMenuPOC" android:icon="@drawable/icon" android:theme="@style/SideMenuPOC">
    </application>
</manifest>

App.cs

<?xml version="1.0" encoding="UTF-8"?>
<Application
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="SideMenuPOC.App">
</Application>

App.xaml.cs

`using System;
using System.Collections.Generic;

using Xamarin.Forms;
using SideMenuPOC.Pages;

namespace SideMenuPOC
{
public partial class App : Application
{
static Application app;
public static Application CurrentApp
{
get { return app; }
}
public App ()
{
InitializeComponent ();
app = this;
var temp = false;

        if (temp)
        {
            //MainPage = new SplashPage();
        }
        else
        {
            GoToRoot();
        };
    }
    public static void GoToRoot()
    {
        if (Device.OS == TargetPlatform.iOS)
        {
            CurrentApp.MainPage = new RootPage();
        }
        else
        {
            CurrentApp.MainPage = new RootPage();
        }
    }
}

}

`

Resources/values-v21/styles.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
  <style name="SideMenuPOC" parent="SideMenuPOC.Base">
    <item name="android:windowDrawsSystemBarBackgrounds">true</item>
    <item name="android:statusBarColor">@android:color/transparent</item>
  </style>
</resources>

Resources/values/styles.xml

<?xml version="1.0" encoding="UTF-8"?>
<resources>
  <style name="SideMenuPOC" parent="SideMenuPOC.Base">
  </style>
  <style name="SideMenuPOC.Base" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="colorPrimary">@color/primary</item>
    <item name="colorPrimaryDark">@color/primaryDark</item>
    <item name="colorAccent">@color/accent</item>
    <item name="android:windowBackground">@color/window_background</item>
  </style>
</resources>

Resources/values/colors.xml

`<?xml version="1.0" encoding="utf-8"?>


#53ba9d
#42947d
#8de2d5
#F5F5F5
`
Resources/layout/toolbar.axml

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    android:minHeight="?attr/actionBarSize"
    android:background="?attr/colorPrimary"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
    app:layout_scrollFlags="scroll|enterAlways" />

Resources/layout/tabs.axml

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.TabLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/sliding_tabs"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="?attr/colorPrimary"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    app:tabIndicatorColor="?attr/colorAccent"
    app:tabGravity="fill"
    app:tabMode="fixed" />

It would be great if any one could explain.

Thanks,
Bhuvanesh

How do i add a button to a Custom Control that inherits off of a ContentPage

$
0
0
public class SignaturePad:ContentPage
{
    public Button getUserSignature;
    public RC_SignaturePad()
    {
       // Put the subscriber here for receiving the byte array from the user
       // This is also the place where the call can be made to send the information over to the WS
        this.getUserSignature.Clicked += getUserSignature_Clicked;

        // How do i add the button(getUserSignature) to this Custom Control??

    }

    void getUserSignature_Clicked(object sender, EventArgs e)
    {
        var userSignature = DependencyService.Get<ISignaturePad>().GetUserSignature();
    }

}

Can i have 2 XAML pages displayed in a 3rd XAML page, using something like a frame?

$
0
0

Say if i have 2 XAML pages. Page1.XAML and Page2.xaml

And i wanted them both to be displayed one below the other inside Page3.XAML, is there a way of doing that in the Xamarin framework?

set volume

$
0
0

Hi,
How to set volume to 70%? Thanks.

Activator.CreateInstance(Type) of a TabbedPage

$
0
0

I am trying to use reflection to activate a type that inherits from TabbedPage. It is failing with a very unhelpful error. I am doing this because I created a mini navigation framework for MasterDetailsPage. I am trying to set the Details page of the MDP to be a TabbedPage. The documentation says you should only use pages that inherit from ContentPage for an MDP details page but I'm not sure why. I'd like to use a TabbedPage in the details page. I'm only using MDP to implement hamburger navigation.

Viewing all 58056 articles
Browse latest View live


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