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

How to increase binded progress property in view model

$
0
0

Hello developers! :smile:

I'm begginer in xamarin ,For some time i'm trying to implement a progress bar which will be increasing by tapping a image assing to it. My problem is that i can't figure out how to get access to Bindable property in my viewmodel. When i copied my model properties to viewmodel still no result, my dream solutions is that model's properties will stay in a model becouse i implement a observable object to this and create observable collection which is binded to listview in my page.xaml file. Can i ask you for some tips or guide my throught this step of my project ?

My code from ViewModel :

` public class SurfBoardViewModel : BaseViewModel
{
public ObservableRangeCollection Boards { get; }
public SurfBoardViewModel()
{

        Boards = new ObservableRangeCollection<SurfBoard>
        {

            new SurfBoard()
            {
                Counter =0.2, Icon="icon.png"
            },
            new SurfBoard()
            {
                Counter= 0.1, Icon="icon.png"
            },
            new SurfBoard()
            {
                Counter =.8, Icon ="icon.png"
            },
            new SurfBoard()
            {
                Counter= .3, Icon="icon.png"
            },
            new SurfBoard()
            {
                Counter = 0.2, Icon="icon.png"
            }
        };



        AddProgressCommand = new Command(AddProgress);

    }

   private void AddProgress()
    {

    }

    public Command SetBusyCommand { get; }
    public Command AddProgressCommand { get; }

//My last step was to copy property from model class and make it observable object to remain all functionality as it was but still no result :neutral:

    public class SurfBoard : ObservableObject
    {
        public SurfBoard()
        {

        }

        double counter;
        public double Counter
        {
            get { return counter; }
            set
            {
                if (SetProperty(ref counter, value))
                {
                    Debug.WriteLine("Counter changed");
                }
            }
        }

        string icon;
        public string Icon
        {
            get { return icon; }
            set
            {
                if (SetProperty(ref icon, value))
                {
                    Debug.WriteLine("Icon Changed");
                }
            }
        }

    }`

Code from page xaml

`

    <ListView x:Name="listView" ItemsSource="{Binding Boards}" HasUnevenRows="True" 
              Margin="10">
        <ListView.ItemTemplate>
            <DataTemplate>
                <ViewCell>

                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="3*"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>


                        <ProgressBar x:Name="progressBar"
                                     Grid.Row="0" Grid.RowSpan="2"
                                     Grid.Column="0"
                                     Progress="{Binding Counter}"
                                     />


                        <Image x:Name="icon"
                                   Grid.Row="0" Grid.RowSpan="2"
                                   Grid.Column="1"
                                   WidthRequest="60"
                                   HeightRequest="60"
                                   Source="{Binding Icon}"
                                   >
                            <Image.GestureRecognizers>
                                <TapGestureRecognizer NumberOfTapsRequired="2"
                                                      Command="{Binding AddProgressCommand}"/>
                            </Image.GestureRecognizers>
                        </Image>


                    </Grid>

                </ViewCell>
            </DataTemplate>
        </ListView.ItemTemplate>
    </ListView>
</StackLayout>`

Saving An object type as a string in SQLite Database (With Sqlite-net-pcl nuget)

$
0
0

Hi, I have a Tag class that I am using to get and save items from the database. I want to know if there is a good and easy way to add Color and Timespan type properties that i could transform into String and Integer before saving to the database.

hastebin.com/abufucijiw.cs (Here is the class code)

Display more than one Image on my page

$
0
0

How can I display 3 image on my xaml page which I have taken earlier (from the gallery)

Custom layout for TabbedPage tabs

$
0
0

Hi.

Can I edit the tabs' layout of a TabbedPage to be like I want?
I mean, I want to customize the tabbar layout with my own, like in the image below:

How can I achieve this?
I need to create a custom User Control? I need to create a custom Layout?

Thank you so much.
I'm very grateful for this community and Xamarin team.

Best regards.

Azure app service not handing control back over to app after successful sign-in.

$
0
0

So I have been trying to implement client authorization for the past few days, specifically with Xamarin Forms on android. My code is heavily based off of James Montemagno's tutorial: Personalized Experiences with Azure Mobile Apps Authentication -it is a Xamarin blow but I can't link due to restrictions.

I am currently having an issue where I get a successful sign-in page on the android web-browser (azure mobile app url with the browser displaying "You have successfully signed in - return to the website") using Google as the identity provider, however, the browser does not return flow back over to the app. I can hit the browsers back button however once back in the app, I am still not logged in.

This is my android manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="schemas[dot]android[dot]com/apk/res/android">
    <uses-sdk android:minSdkVersion="20" />
    <application android:label="BookDB.Android">
      <activity android:name="com[dot]microsoft[dot]windowsazure[dot]mobileservices[dot]authentication[dot]RedirectUrlActivity" android:launchMode="singleTop" android:noHistory="true">
        <intent-filter>
          <action android:name="android.intent.action.VIEW" />
          <category android:name="android.intent.category.DEFAULT" />
          <category android:name="android.intent.category.BROWSABLE" />
          <data android:scheme="bookdbase" android:host="easyauth.callback" />
        </intent-filter>
      </activity>


  </application>
</manifest>

And this is the Android implementation of the IAuthetication interface which I call from my PCL.

 public class Authentication: IAuthentication
        {
            public async Task<MobileServiceUser> LoginAsync(MobileServiceClient client, MobileServiceAuthenticationProvider provider)
            {
                try
                {
                    var user = await client.LoginAsync(provider,"bookdbase");


                    Settings.AuthToken = user?.MobileServiceAuthenticationToken ?? string.Empty;
                    Settings.UserId = user?.UserId ?? string.Empty;


                    return user;
                }
                catch (Exception e)
                {
                    e.Data["method"] = "LoginAsync";
                   // Xamarin.Insights.Report(e); 
                }

                return null;
            }
        }

If anyone could shed some light on this or perhaps point me in the direction of help, that would be much appreciated.

thanks.

How to get live/continious audio stream from mobile microphone

$
0
0

is it possible to get live audio stream from mobile mic with specified PCM format, so that I can use that stream in a socket connection.

How to write logs to file?

$
0
0

I am building my project using .NET Standard. Is there any way to write logs to file in Xamarin?

Error MT2002

$
0
0

Xamarin Forms project, visual studio 2017 15.9.4. I compile a project with connection to macbook.
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(795,3): error MT2002: Can not resolve reference: /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/mono/Xamarin.iOS/Facades/System.Resources.Reader.dll


Unable to get circle image in plugin?

Hide a specific child page of a CarouselPage

$
0
0

Hi Guys,

I need a way to hide a specific carousel page. I do not want to remove the page as a whole because then I would lose all the changes made on that particular page which I want to maintain like Field changes, Scroll position, control states and so on. Possible? I dont mind using TabbedPage is this feature is only possible on that.

Thanks.

How to detect if the device "notch", the model or the height of the screen (from shared code)?

$
0
0

I want to put a margin / padding top if the device is iOS and has notch.
And I want to do it from the generic code not using the specific iOS project.

I've been looking for a lot and I think I can not check if it has notch and not know if it's an iPhone X, so...
- I can not know the model of the device
- I can not know if the device has notch
- Can I know the height and orientation of the device?

If possible I could do the following:
if (
(Device.RuntimePlatform == Device.iOS) // Ok
&& (check orientation == portrait)
&& (check height device == XXXX)
){
Padding = new Thickness(0, 20, 0, 0);
}

How to solve the below issue which i am getting while writing UI tests

$
0
0

This is a simple UI test which I have created for a Xamarin.Forms application and I am getting this error while running tests.

Let me know how to solve this issue.

XAML Learning Curve

$
0
0

Hi everyone,

Most of the time, I am developing apps using Xamarin.iOS and I am comfortable with it. But this time, I got one more job that requires the same app for Android version. Since I have no knowledge of XAML, I thought that it is better to start with Xamarin.iOS and then developing the app with Xamarin.Android.

I need to develop the app in 3 months for both iOS and Android version.

What are your experience for learning XAML? Do you think it is better to focus on Xamarin.Forms rather than Xamarin.Native? or should I stick with what I am comfortable with because of time limitation?

Thank you very much!

Google Drive Rest API

$
0
0

Hi, I am trying to implement a feature in my app where the user logs in on their Google account and can upload/download to their Drive.
I have a functioning solution using Android.Gms.Drive, and Android.Gms.Auth.Api.SignIn, but, unsurprisingly this only works for android and with the deprication of Google Drive Android API, this will need to be migrated to the rest api anyway.

The question I have is, are there any good tutorials for implementing this? The one I find aren't intended for Xamarin, along with the fact that I am uncertain which libraries are best for the situation.

Any suggestions are appreciated.
Thank you for your time and assistance.

NFC Reader for iOS11 App

$
0
0

Hello,

Now that Apple has exposed the NFC APIs for the app development and we can create iOS 11 apps to read/write NFC tags, we wanted to create an iOS App (using Xamarin forms or native iOS using .net) for the same. So just wanted to know if there are any updates to Xamarin Forms that would allow us to create the app.


Source Reference for binding in a standalone resource dictionary to the a content page context

$
0
0

What should the binding source reference for be in a Xamarin forms 3 standalone resource dictionary? Given the following XAML:

<DataTemplate x:Key="newAddressTemplate">
    <ViewCell>
        <ViewCell.View>
            <Label TextColor="{Binding LabelColorName}" Text="{Binding Label}" VerticalOptions="CenterAndExpand" HorizontalOptions="CenterAndExpand">
                <Label.GestureRecognizers>
                    <TapGestureRecognizer Command="{Binding Path=BindingContext.NewAddressCommand, Source={x:Reference Page}}" CommandParameter="{Binding AddressDestinationType}" />
                </Label.GestureRecognizers>
            </Label>
        </ViewCell.View>
    </ViewCell>
</DataTemplate>

The TapGestureRecognizer Command binding works if the resource dictionary is in the content page itself (where the content page includes x:Name="Page"), but not when it is moved to a standalone file containing only the resource dictionary. Adding x:Name="Page" to the resource dictionary tag doesn't resolve the issue. It seems like the reference should be to parent whatever that might be.

How to add checkbox in xamarin.forms?

$
0
0

I am wondering how to do that with full functionalities.
I have created that thanks to this answer but I couldn't handle the check/uncheck events so how to handle that?

XamarinForms APK won't install

$
0
0

We have two apps which are deployed using HockeyApp (Ad Hoc deployment).
After recent updates on my Mac (iOS & Visual Studio Community) I can't install them on Android devices (deployment to iOS devices steill works fine).

I have a message "App not installed".
It is the same when I try to install from APK file on the device (signed or unsigned apk).
I can install the app on the phone in Release mode when I have it connected to the Mac.

I'm not sure what else I should check to investigate this issue?

Visual Studio Community version 7.6.1 (build 9)
iOS version 10.13.16
HockeyApp.SDK.Xamarin 5.1.2
Xamarin.Forms 3.1.0.697729

Add a reference to assembly

$
0
0

Hi to all,

I want to add Xlabs to my project, so I read how to implement it ( https://github.com/XLabs/Xamarin-Forms-Labs/wiki ).

I found this problem:

when I try to add this code to "App.cs" in my WinPhone 8.1 project

var app = new XFormsAppWP();
app.Init(this);

on "Init" (app.Init(this)) I had this problem:

The type 'Application' is defined in an assembly that is not referenced.
You must add a reference to assembly 'System.Windows, Version=2.0.6.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
'

I have a "Quick Fix" option -> Add a reference to assembly 'System.Windows, Version=2.0.6.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e', but when I try to click on it, nothing happens.

In "Reference Manager" (WinPhone project -> Right click -> Add reference) I can't add this reference because I can't found it.

I using Visual Studio 2015 pro, Xamarin.Forms PCL.
My project targeting .NET 4.5 (I tried also with 4.5.2 but I had the same problem).

How can I resolve this problem?

Navigation via popasync after saving data

$
0
0

I am using MVVM view model to save data. A view model command gets invoked when the user saves the data after clicking on the Toolbaritem button "Save". After saving the data I want to return to the previous page. I could always invoke popasync in the clicked event from the code behind however, that would require the saving to be done in the code behind instead of the view model which is a bad practice as the view should not be aware of any data related aspects. On the other hand I don't want to invoke popasync in view model as it will mean the view model should have knowledge of the views and navigation which is again a bad practice? Whats the best design pattern to achieve this? Is it possible to invoke both the command and clicked event on the same button?

Viewing all 91519 articles
Browse latest View live


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