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

Xamarin.forms Firebase analystics.

$
0
0

I have implemented Firebase analytics tool in Xamarin.forms application, and i unable to create custom event

**public partial class FeedPage : ContentPage
{
IFirebaseAnalytics eventTracker;
public FeedPage()
{
InitializeComponent();
eventTracker = DependencyService.Get();
}

    void Handle_Clicked(object sender, System.EventArgs e)  
    {  
        eventTracker.SendEvent("Click1");   // Custom event 
    }  
}**

This custom event throw the error System.NullReferenceException: 'Object reference not set to an instance of an object.'


why navigation between pages in xamarin forms is slow on Android

Get file path from content.

$
0
0

Hi everyone,

I have a Xamarin.Forms (iOS, Android) app and I open it as option to Open PDF documents. For Android app, I set an intent-filter with mimetype: pdf.

  <intent-filter>
          <action android:name="android.intent.action.VIEW" />
          <category android:name="android.intent.category.DEFAULT" />
          <data android:mimeType="application/pdf" />
        </intent-filter>

Is there any way to do the same thing on iOS?

And I have another problem. After I open my app, I want to retrieve the file's path from intent, but I get something like that:
content://com.android.providers.downloads.documents/document/22

Is there any way to get the file path from that content?

Thank you.

Shell MenuItem binding problem

$
0
0

Hi all.
My Label in Shell MenuItemTemplate can't see property from ViewModel (last item in XAML)

<?xml version="1.0" encoding="UTF-8"?>
<Shell xmlns="http://xamarin.com/schemas/2014/forms" 
       xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
       xmlns:d="http://xamarin.com/schemas/2014/forms/design"
       xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
       mc:Ignorable="d"
       xmlns:views="clr-namespace:BillingMobile.Views"
       xmlns:markupextensions="clr-namespace:BillingMobile.Xaml.MarkupExtensions"
       xmlns:materialIcons="clr-namespace:BillingMobile.Icons"
       xmlns:rounded="clr-namespace:BillingMobile.Controls.Rounded"
       Title="BillingMobile"
       x:Class="BillingMobile.AppShell"
       Style="{DynamicResource BaseStyle}">

    <FlyoutItem Title="Меню" FlyoutDisplayOptions="AsSingleItem" FlyoutIcon="wallet.png">
        <Tab Title="{markupextensions:TranslateExtension Wallet}" Icon="wallet.png">
            <ShellContent ContentTemplate="{DataTemplate views:AccountPage}" />
        </Tab>
        <Tab Title="{markupextensions:TranslateExtension MyCompany}" Icon="account_group.png">
            <ShellContent Title="{markupextensions:Translate Services}" ContentTemplate="{DataTemplate views:AccountPage}" />
            <ShellContent Title="{markupextensions:Translate Users}" ContentTemplate="{DataTemplate views:AccountPage}" />
            <ShellContent Title="{markupextensions:Translate Departments}" ContentTemplate="{DataTemplate views:AccountPage}" />
        </Tab>
        <Tab Title="{markupextensions:TranslateExtension Notifications}" Icon="bell_ring.png">
            <ShellContent ContentTemplate="{DataTemplate views:AccountPage}" />
        </Tab>
    </FlyoutItem>

    <Shell.FlyoutHeader>
        <Grid Padding="15">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <Image Grid.Row="0" HeightRequest="70" HorizontalOptions="Start" VerticalOptions="Center" WidthRequest="70" x:Name="image">
                <Image.Source>
                    <FontImageSource FontFamily="{DynamicResource MaterialFontFamily}" Glyph="{x:Static materialIcons:MaterialDesignIcons.AccountCircle}" Size="70" Color="{StaticResource PrimaryColor}"/>
                </Image.Source>
            </Image>
            <Label Grid.Row="1" Text="Кравченко Ігор Андрійович" FontAttributes="Bold" TextColor="{StaticResource PrimaryColor}"/>
            <Label Grid.Row="2" Text="{Binding SelectedTheme}" TextColor="{StaticResource PrimaryColor}"/>
        </Grid>
    </Shell.FlyoutHeader>

    <MenuItem>
        <Shell.MenuItemTemplate>
            <DataTemplate>
                <StackLayout Orientation="Horizontal" Padding="15">
                    <Image Grid.Row="0" HeightRequest="24" HorizontalOptions="Start" VerticalOptions="Center" WidthRequest="24">
                        <Image.Source>
                            <FontImageSource FontFamily="{DynamicResource MaterialFontFamily}" Glyph="{x:Static materialIcons:MaterialDesignIcons.Brush}" Size="24" Color="{StaticResource PrimaryColor}"/>
                        </Image.Source>
                    </Image>
                    <Label PropertyChanged="OnLabelPropertyChanged" Text="{Binding ThemeTitle}" VerticalOptions="Center" VerticalTextAlignment="Center" TextColor="Black"/>                       
                </StackLayout>
            </DataTemplate>
        </Shell.MenuItemTemplate>
    </MenuItem>
</Shell>

ViewModel:

public class ShellViewModel : BaseViewModel
    {
        public string ThemeTitle
        {
            get { return "Light"; }
        }

        public ShellViewModel()
        {

        }        
    }

The text in Label is always empty.
BUT!
In method OnLabelPropertyChanged I see how the text is binded to label.

Another BUT
When I set Text without binding all works:

<Label PropertyChanged="OnLabelPropertyChanged" Text="Light" VerticalOptions="Center" VerticalTextAlignment="Center" TextColor="Black"/>

I am using Xamarin 4.3.0.819712-pre2

The type or namespace name 'Android' does not exist in the namespace 'Xamarin.Forms.Platform'

$
0
0

Hi guys.
I Updated my nuget packages few days ago to new versions.
but my Android project has 2 errors in MainActivity.cs:
1:
The type or namespace name 'Android' does not exist in the namespace 'Xamarin.Forms.Platform' (are you missing an assembly reference?) Sama.SamaApp.Android MainActivity.cs

2:
'MainActivity.OnCreate(Bundle)': no suitable method found to override MainActivity.cs

i search it in google and find solutions.

But i tested all solutions in two up links but not worked for me.
i tested clear nuget and dotnet caches . removing bin & obj folders . restore nuget packages . remove and reinstall Xamarin.Forms .finally clean rebuilding the solution.
But I could not fix it.
thanks...

Best way to implement an ObservableCollection whose objects are accessible from multiple views?

$
0
0

I am fairly new to Xamarin. I'm currently working on a project and am trying to use best MVVM practices in building it. I've successfully implemented the MVVM pattern for my login page and I have a pretty good grasp on that, but it is a little more straight forward than what I'm trying to do now.

Once you log in you're brought to a TabbedPage. The TabbedPage contains two ContentPages, one with a ListView. My goal is to create an ObservableCollection which can be accessed by both of the ContentPages in the TabbedPage but I'm not sure where the correct place to create this ObservableCollection would be.

Should I create a ViewModel for the TabbedPage and have the ObservableList live there and have the ViewModels for the two ContentPages access that ViewModel? Should I create the ObservableList in the ViewModel of the first ContentPage with the ListView and have the second ContentPage reference that ViewModel?

I've tried looking for resources to understand this particular scenario but I haven't been able to find any that discuss multiple views referencing the same ObservableList. I'd be very grateful for either an explanation on the best way to do this, or a link to a resource that would explain or exemplify this. Thanks!

I should also note that I currently have the ObservableList living in the code behind for the ContentPage with the ListView. I know this is not where it should be but I just wanted to make sure I could get the ListView working with an ObservableList and I am now looking to move it to where it should be.

Center frame in a tablet screen

$
0
0

How to have a frame centered in the screen. The frame will have only a Label, an Entry of maximum 6 numbers width and a button.

Appropriate an iOS distribution - certificates, profiles, ...

$
0
0

Hi all,

Context:
I have the task of putting into production an application made by a tier, which will be called TA to update an application made historically by the company CB. TA has recoded the entire application, so it is more like the old, but I want to release the version under the guise of an update to not lose the thousands of users of the application. It remains the same application. My problem is that I can't take ownership of the signature entities and make Visual Studio detect signing certificates.

Actual config:
Certificate
Provisionning Profile
App ID
Archive Visual Studio

I have test with XCode, and XCode in Auto Sign add CB in the Signing Certificate, but, this certificate not exist today and it is not linked with this App ID.

Today I am completely helpless and I really have no idea how to do it. I spent 2 days, so I passed my dead line. If a charitable soul could yell me, I thanked him for it.

Thanks for your help.


Firebase Analytics-Manual Screen Views are not getting tracked in correct order for Xamarin.iOS

$
0
0

Hello,
I am integrating firebase analytics in Xamarin.Forms project.Screen views are not getting tracked in correct order for iOS project.I am using below line of code in respective file's on appearing method-

LoginPage.xaml- Analytics.SetScreenNameAndClass("LoginScreen", null);
Dashboard.xaml- Analytics.SetScreenNameAndClass("DashboardScreen", null);
Employee.xaml- Analytics.SetScreenNameAndClass("ViewEmployeeScreen", null);

The above line of code is written in xamarin ios project and I am using dependency service to call it from PCL of xamarin forms.
For eg user flow is Login->Dashboard->ViewEmployee
In DebugView
Expected scenario shoud be : LoginScreen-> DashboardScreen(screen_view1) & DashboardScreen-> ViewEmployeeScreen(screen_view2)

Result I am getting: LoginScreen-> DashboardScreen(screen_view1), DashboardScreen->LoginScreen(screen_view2),LoginScreen->EmployeeScreen(screen_view3) . (Which is incorrect It should not go to login screen again)

Packages installed:
Xamarin.Firebase.iOS.Analytics(6.0.4)
Xamarin.Firebase.iOS.Core(6.1.0)
Xamarin.Firebase.iOS.Crashlytics(3.14.0)
Xamarin.Firebase.iOS.InstanceID(3.4.0)
Can anyone please let me know where I am going wrong?

Thanks in advance!

Picker when placed inside Listview is not working properly.

$
0
0

Xamarin.Forms: I have used a ListView and created a DataTemplate as custom ViewCell with Grid inside the same.
In my Grid I have created 3 Columns with picker inside first column and Entry as second and third column.
Whenever I click upon entry cell or TextChanged event is triggered, Picker in other column is also focused and picker item selection pop up is displayed.

TitleView for ContentView

$
0
0

Hi,

How can assign NavigationPage.TitleView to a ContentView?

Thanks,
Jassim

Adding Privacy statement in Sign in process in Azure AD

$
0
0

Hi,

I am using Azure AD sign process to my Mobile application, Here I added privacy policy link to user to accept before they go through the app.
When I click on the Privacy statement link and click back on Android device expectation is to go back to Consent screen, but right now whats happening is the sign in process is cancelling,

Error: System.AggregateException: 'One or more errors occurred. (Cannot create a table without colum

$
0
0

I am trying to use a local SQLite database in my Xamarin application

When loading the ListView page that I'm testing it on I always get the error: System.AggregateException: 'One or more errors occurred. (Cannot create a table without columns )'

Here is the applicable code:

PieceDatabase.cs

namespace TestApp1
{
  public class PieceDatabase
  {
    readonly SQLiteAsyncConnection _database;

    public PieceDatabase(string dbPath)
    {
        _database = new SQLiteAsyncConnection(dbPath);
        _database.CreateTableAsync<Piece>().Wait();
    }

    public Task<List<Piece>> GetPieceAsync()
    {
        return _database.Table<Piece>().ToListAsync();
    }

    public Task<int> SavePieceAsync(Piece temp)
    {
        return _database.InsertAsync(temp);
    }
}

}
App.xaml.cs

namespace TestApp1
{
public partial class App : Application
{

    static PieceDatabase database;

    public static PieceDatabase PieceDatabase
    {
        get
        {
            if (database == null)
            {
                database = new PieceDatabase(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "pieces.db3"));
            }
            return database;
        }
    }

    public App()
    {
        InitializeComponent();
        MainPage = new NavigationPage(new Page1());
    }

}
DatabaseTest.xaml.cs

namespace TestApp1
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class DatabaseTest : ContentPage
{

    protected override async void OnAppearing()
    {
        base.OnAppearing();

        /** The error does not occur if I add a piece here, but I'm trying to figure out why that is
        await App.PieceDatabase.SavePieceAsync(new Piece
        {
            Catagory = "Beams",
            PartNum = 1,
            Url = "whatever.com"
        }); */

        List<Piece> test = await App.PieceDatabase.GetPieceAsync();
        listView.ItemsSource = test;
    }

    public DatabaseTest()
    {
        InitializeComponent();

    }

    async void Handle_ItemTapped(object sender, ItemTappedEventArgs e)
    {
        if (e.Item == null)
            return;

        await DisplayAlert("Item Tapped", "An item was tapped.", "OK");

        //Deselect Item
        ((ListView)sender).SelectedItem = null;
    }
}

}

WebView Inside a ScrollView not working

$
0
0

Hi,

I have a simple WebView inside a ScrollView but the problem it's not scrolling anything.

here is my code:

<ScrollView Grid.Row="0">
    <Grid Grid.Row="0" RowSpacing="0">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <SyncfusionRotator:SfRotator x:Name="RotatorAdDetails" Grid.Row="0" EnableLooping="False" EnableAutoPlay="False" NavigationDelay="4000" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
            <SyncfusionRotator:SfRotator.HeightRequest>
                <OnIdiom x:TypeArguments="x:Double" Phone="300" Tablet="400" />
            </SyncfusionRotator:SfRotator.HeightRequest>
            <SyncfusionRotator:SfRotator.ItemTemplate>
                <DataTemplate>
                    <StackLayout ClassId="{Binding user_guid}">
                        <FFImageLoading:CachedImage Source="{Binding media_file}" ClassId="{Binding ad_guid}" LoadingPlaceholder="AdPlaceholder.png" FadeAnimationEnabled="True" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Aspect="AspectFill" DownsampleToViewSize="true">
                        </FFImageLoading:CachedImage>
                    </StackLayout>
                </DataTemplate>
            </SyncfusionRotator:SfRotator.ItemTemplate>
        </SyncfusionRotator:SfRotator>

        <WebView x:Name="WebViewAdDetailsDescription" Grid.Row="1" Margin="5" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" />
    </Grid>
</ScrollView>

How can I fix that please?

Thanks,
Jassim

How to notify or call viewmodel 's method from customview 's bindable property

$
0
0

Hi All, I need to call viewmodel method from customview whenever bindable property changed.

public class CustomPieChart : SupportPieChartExtended
{
    public static readonly BindableProperty SelectedValueProperty = BindableProperty.Create(nameof(SelectedValue), typeof(string), typeof(CustomPieChart), null);
    public string SelectedValue
    {
        get { return (string)GetValue(SelectedValueProperty); }
        set { SetValue(SelectedValueProperty, value);

        }
    }
}

I am setting this value from customrenderer of CustomPiechart which I am able to but I need to call a method of viewmodel .

public class PaySlipPageViewModel : BaseViewModel
{
     public string SelectedValuesSet
     {
        get => selectedValuesSet;
        set {
            SetProperty(ref selectedValuesSet, value); 
        Hello();}
     }

public void Hello(){
{
    Console.WriteLine("Hello");
}
}

In the UI

 <customControls:CustomPieChart x:Name="pieCharts"
                                         SelectedValue="{Binding SelectedValuesSet, Mode=TwoWay}"
                                             HeightRequest="350"
                                               WidthRequest="350"
                                              DrawCenterText="True"
                                              HorizontalOptions="FillAndExpand"
                                               VerticalOptions="FillAndExpand">

I need to reflect SelectedValuesSet from CustomPieChart Class whenever SelectedValue changed.

Please help


Can I have more than one ResourceDictionary?

$
0
0

I have now one ResourceDictionary with all my styles for buttons, frames, labels.. etc.
but I want to have now two or more then I would choose one of then to use.

CarouselPage: How to move to other page clicking on a button in the nav bar?

$
0
0

this is my CarouselPage:

My first page

If I slide "Right to left"

Goes to my second page

I want to move from the first page to the second in the same way as now but also clicking on that button (shopping cart) and if I click it send me to the other. That's possible?

Xamarin.Forms Events vs UWP Events

$
0
0

I am a UWP developer and am attempting to convert my apps to Xamarin.Forms for use by Android. I supposedly found enough of the XAML controls to make the UI, but the events are much more challenging. Is there anywhere that I can find a list with a comparison of UWP events & their suggested replacements in Xamarin.Forms? Some of the events that I have been told require the most rewriting for are the lifecycle (such as Page.Loaded). Are there pages anywhere with guidelines on portability for events? Thanks.

Scanning Multiple info in Single QR code and display the data in different fields

$
0
0

Hi,

Currently I am working on QR code scanner, I want the single QR code which contains multiple data (number, text, url) and display the data in different fields,

how do i make xamarin forms connect to a node js server on firebase hosting

$
0
0

im making a cross platform ios and android app and have a node js backend with firebase hosting and saving information to firebase database. how do i connect the xamarin forms front end to the node js backend and make them communicate. i can save info from the clientside but its not secure and i can save info in node js but i need to take strings from clientside such as username and email. how do i do this securly such as using crypto?

Viewing all 91519 articles
Browse latest View live


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