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

Is there a way to determine if you are on the Main thread?

$
0
0

In Windows Forms, all controls had an InvokeRequired property that returned true if the current thread was not the UI thread. This allowed a boilerplate pattern for ensuring a method that could be called from multiple contexts was always called from the right one:

if (someControl.InvokeRequired) {
    someControl.Invoke(() => ThisMethod());
} else {
    // do stuff
}

I know in Xamarin.Forms I can use Device.BeginInvokeOnMainThread() to marshall a call to the main thread, but is there a way to detect if I'm on the main thread? That would be helpful for creating classes that represent things with thread affinity and want to enforce it.


Xamarin.Forms Android Build/Deploy failed

$
0
0

Hi,

I am new to Xamarin and Xamarin.Forms. I am trying to start an Xamarin.Forms (Portable) project and when I am trying to deploy for Android I get some missing resources errors (Build log attached).

I also searched for a solution and after trying removing NuGet Packages (all are up to date) and reinstalling, deleting %appdata% local xamarin folders as described in this solution, but still getting the same error.

Can you help me fix it?

[EDIT]
I have Android SDK installed by Android Studio but updated and Xamarin Settings pointing to it's location.

Thank You!

Br,
Iosif

Drawer/Slider Layout windows phone

$
0
0

Is there any alternative Drawer/slider pages, layout controls for windows phone8.1 available in xamarin.forms rather then masterdetailpage
(I Created using Masterpagedetails its pop ups from bottom, i want it to open as side navigation slider )

MediaPicker Not Working with Xamarin.Forms

$
0
0

I am new to xamarin.in my project open gallery for select image for this i have used IMediaPicker interface.my code as below:

    IMediaPicker mediaPicker;
    ImageSource imageSource;
    async void OnTapEntertainer(object sender, EventArgs args)
    {
       await TakePicture();
    }

    private async Task TakePicture()
    {
            mediaPicker = DependencyService.Get<IMediaPicker>();
            imageSource = null;
            var mediaFile = await mediaPicker.SelectPhotoAsync(new CameraMediaStorageOptions
            {
                DefaultCamera = CameraDevice.Front,
                MaxPixelDimension = 400
            });
            imageSource = ImageSource.FromStream(() => mediaFile.Source);
            Imgmn.Source = imageSource;
    }

I got mediaPicker is null value in this code.Please help me to solve this issue. I have added capability required for perform function.

bind objective-C iOS SDK into Xamarin.forms

$
0
0

Hi All,

Just wondering if it is possible to bind objective-C iOS SDK into Xamarin.forms, or only it is possible for Xamarin.iOS?

I am currently working a Linea Pro Project. Anybody has experience on it?

Thanks

Ting

How to disable double tap on a button into android

$
0
0

Hello all,

i develop an cross mobile application and i have a problem, when a user tap twice on a button which launch a contentPage to scanner a QRCode my application crash. I understrand why, but how can i disable a double tap on this button ? I've try to disable this button, to remove delegate but it's always the same problem and i don't found any solution at my issue....so, if you've some idea to solve my problem... Thanks :)

Adal authentication 4 preview for Xamarin.Forms

Showing Secondary ToolBar items - best way?

$
0
0

I use two devices for testing my app:

  1. Phone(Android 4.0.3). It has a hardware button menu
  2. Tablet(Android 4.2.2). It has no hardware button menu.

This is code my ToolBars

  <ToolbarItems >
    <ToolbarItem Text="Action1"  Order="Primary" />
    <ToolbarItem Text="Action2"  Order="Secondary" />
    <ToolbarItem Text="Action3"  Order="Secondary" />
 </ToolbarItems>

When I run app on the phone button with secondary items not showing.

I need to press the menu button that would showing secondary items.
When I run app on the tablet button with secondary items showing. This is normal?
I tried to use this code:

           ViewConfiguration config = ViewConfiguration.Get(this);
            Field menuKeyField = config.Class.GetDeclaredField("sHasPermanentMenuKey");

            if (menuKeyField != null)
            {
                menuKeyField.Accessible = true;
                menuKeyField.SetBoolean(config, false);
            }

I first run app on the phone button with secondary items not showing. Second and other run - button with secondary items showing.
But this hack. The default behavior of the application is that normal? What do you do in this case?


Adding toolbar items, buttons and menus

$
0
0

OK, I'm making and assumption here becasuse I haven't run it up yet. When a ToolBarItem item is added the icon to the device tool bar, in the case of WP this would be application menu bar - the _ToolBarItem _would render as an application bar button, providing the icon adheres to the WP restrictions. Is there a standarised way / preferred mechanism to render menu items rather than buttons? i.e. provide a menu off the tool bar, in WP these would render as the application menu items.

Xaml BindingContext not working

$
0
0

Hello

Can anyone tell me why this is the case:

Works:

var e2 = new Entry
      {
           BindingContext = bla
      };
     e2.SetBinding(Entry.TextProperty, new Binding("PRJDESCR"));

Doesn't work:
<Entry BindingContext="{Binding local:bla}" Text="{Binding PRJDESCR}"/>

bla is a public property on page and has a own property "PRJDESCR".

Implementing WCF Service with a Callback (bidirectional)

$
0
0

Hi developers,

I have a question regarding to an WCF service.
At my curent project I'm looking for a way to implement a chat service and client (App). That means I need a solution to send data from the service directly to the (listening) App.

I'm using a few WCF services for my App and a common way to do this seems to be the use of Callbacks, a integrated feature of WCF.
The howto article I used is this one: http://blog.the-blair.com/2010/04/02/wcf-tutorial.html
The code can be found here: https://github.com/dongola7/wcf_chatter

To create the proxy I tried the Visual-Studio way ("Add service reference...") and the command line tool "SlSvcUtil.exe". And I got a few errors:

Fehler 4 Der Typ- oder Namespacename 'DuplexClientBase' ist im Namespace 'System.ServiceModel' nicht vorhanden. (Fehlt ein Assemblyverweis?) C:\Entwicklung\SVN........\Service References\ChatApiReference\Reference.cs

I'm using this proxy class in my Portable Class Library.

My question: is there a solution to use a such a proxy class in a Xamarin-Forms CPL ? And if yes, how ? :-)

Change Image opacity while touched.

$
0
0

Hello,
I would like to change an image opacity while it's been touched ie: change opacity when finger is down, restore when finger is up, then handle Tapped event. I couldn't find any hint...
I'm using Xamarin Forms 2.2.0.31 and I need this functionality on both iOS and Android.
Any clue would be very much appreciated. Please note that I am not using XAML as per my client request. So any example must be in C# only.

Thank you in advance for your help.
M.

To show dynamic collection of data inside listView's ViewCell

$
0
0

I want to show collection of items in each ViewCell of List view.

I found one line which I have found it useful but not fully helpful.
Link: stackoverflow.com/questions/31068680/how-to-create-a-grid-inside-a-listview-binding-xamarin-forms

It says to use grid as itemtemplate for listview's viewcell but it did not explain, how would I count number of child element for each viewcell.

 'var myDataTemplate = new DataTemplate(() =>
        {
            var cell = new ViewCell();
            var grid = new Grid();

            foreach (var record in myRecords)
            {
                grid.RowDefinitions.Add(new RowDefinition());
            }

            foreach (var field in myFields)
            {
                grid.ColumnDefinitions.Add(new ColumnDefinition());
            }

            /*
             *
             * Populate grid here...
             *
             */

            cell.View = grid;
            return cell;
        });'

Other logic I was thinking was to use list inside list but it is not working.

XML Json converters missing from Newonsoft.Json?

$
0
0

In my current project I (unfortunately) have a need to convert Json from an external web service into XML. It appears that the Newtonsoft Json library has functionality for that, such as JsonConvert.DeserializeXNode or the XNodeConverter class. Unfortunately, neither of those exist when I try and use them in my project. Is this a shortcoming of the PCL version of the Newtonsoft Json library, or am I missing something?

Trying to compile
JsonConvert.DeserializeXNode(httpString);
results in
Error CS0117 'JsonConvert' does not contain a definition for 'DeserializeXNode' MiosPCL C:\Users\Ronald\Source\Repos\HomeWave\HomeWave\HomeWave\MiosPCL\UserData.cs 95

SQLite UWP

$
0
0

Hey guys, I'm working with SQLite in Xamarin.Forms and I'm a noob for a while :), I had started with the guide instructions, to Android working well, but in the UWP project the interface implemantation doesn't work, show me that no reference to SQLiteConnection in portable interface, someone know something about that?


using skia sharp to draw a radio button

$
0
0

Has anyone tried skia sharp in designing a radio button ?
I have done that using ncontrol but seeing the limited support it is getting i want to move to skia sharp but not able to understand how to implement touch gestures in skia sharp views.

ContentView For ListView Item

$
0
0

Hi all,

I want to use a content view for item temple inside my list view.

my code :

ListView lister;
lister = new ListView();
lister.ItemTemplate = new DataTemplate(typeof(MyBandNewsSuperCell));
lister.ItemsSource = newslist;

and MyBandNewsSuperCell is a ContentView with xaml here is code:

namespace App
{
    public partial class MyBandNewsSuperCell : ContentView
    {
        public MyBandNewsSuperCell()
        {
            InitializeComponent();

            profilimg.SetBinding(RoundedImageView.SourceProperty, "UserAvatar");
            hourlabel.SetBinding(Label.TextProperty, "Hour");
            firstnamelabel.SetBinding(Label.TextProperty, "FirstNameUser");
            lastnamelabel.SetBinding(Label.TextProperty, "LastNameUser");

        }
    }
}

And here is xaml :

<ContentView xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="App.MyBandNewsSuperCell"
             xmlns:local="clr-namespace:App;assembly=App"
             xmlns:i18n="clr-namespace:App<del></del>;assembly=App">
  <ContentView.Content>
    <Grid x:Name="maingrid" AbsoluteLayout.LayoutBounds="0,0,1,0.2" AbsoluteLayout.LayoutFlags="All" BackgroundColor="{StaticResource ColorWhite}" RowSpacing="1" IsVisible="true" ColumnSpacing="0">
      <Grid.RowDefinitions>
        <RowDefinition Height="2*" />
        <RowDefinition Height="28*" />
        <RowDefinition Height="68*" />
        <RowDefinition Height="2*" />
      </Grid.RowDefinitions>
      <Grid.ColumnDefinitions>
        <ColumnDefinition Width="2*" />
        <ColumnDefinition Width="15*" />
        <ColumnDefinition Width="20*" />
        <ColumnDefinition Width="61*" />
        <ColumnDefinition Width="2*" />
      </Grid.ColumnDefinitions>
      <BoxView BackgroundColor="{StaticResource ColorGrey}" Opacity="0.7" Grid.Row="0" Grid.Column="0" Grid.RowSpan="4" Grid.ColumnSpan="5" />
      <Image x:Name="profilimg" Grid.Row="1" Grid.RowSpan="2" Grid.Column="1" />
      <Label x:Name="hourlabel" Style="{StaticResource BlackColorNormalSize}" Grid.Row="1" Grid.Column="2"/>
      <StackLayout Orientation="Vertical" Grid.Row="2" Grid.Column="2" >
        <Label x:Name="firstnamelabel" Style="{StaticResource FontWhiteAndCenter}"/>
        <Label x:Name="lastnamelabel" Style="{StaticResource FontWhiteAndCenterLittleFont}"/>
      </StackLayout>
    </Grid>
  </ContentView.Content>
</ContentView>

But when i compile i had an error "Specified cast is not valid.", any one have an idea for resolve my problem?

Sorry for my english and thanks in advance.

I want to create shop cart for my app adding items for list to cart can anyone please help me with

$
0
0

shop cart functionality in xamarin form app

radio button to select items in a list?

$
0
0

can anyone help me with selecting multiple item by checkbox, radio button ,tick mark anything like that but in xamarin form

How to use XLabs.MediaPicker control?

$
0
0

Following the Description for XLabs Camera, I created a project and created the CameraViewModel and CameraPage. But running the solution it just displays the 3 buttons but clicking the buttons does nothing. It appears I am missing something, as the Setup() method is never called.

On searching this forum found some threads but what is said in there is not clear. So what am I missing?

Normally we initialize the view model in the master page. But I don't see any such statement in the CameraPage.xaml.cs. Few threads suggested initializing a Renderer but the given code is confusing.

So how do I make this working?

Viewing all 58056 articles
Browse latest View live


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