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

NullReferenceException on Grid.CalculateAutoCells [Only XF iOS]

$
0
0

Hi,

I'm developing an app with Xamarin Forms from 7 months.
My app worked very well.
I have done 1 month on Android side, because I fixed some bugs and added some features.

Today I have ported these mods on iOS side and now I have a NullReferenceException on Grid, when I scroll the List View. (On Android all works perfectly)

Here's what happens:
- I open the page that contains the list
- The list is loaded and displayed correctly
- If I try to scroll through the list, appears this exception

Stack Trace:

at Xamarin.Forms.Grid.CalculateAutoCells (System.Double width, System.Double height) [0x00357] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\GridCalc.cs:144 at Xamarin.Forms.Grid.MeasureGrid (System.Double width, System.Double height, System.Boolean requestSize) [0x0000c] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\GridCalc.cs:483 at Xamarin.Forms.Grid.LayoutChildren (System.Double x, System.Double y, System.Double width, System.Double height) [0x0000e] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\GridCalc.cs:17 at Xamarin.Forms.Layout.UpdateChildrenLayout () [0x000c7] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\Layout.cs:229 at Xamarin.Forms.Layout.OnSizeAllocated (System.Double width, System.Double height) [0x0000f] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\Layout.cs:194 at Xamarin.Forms.VisualElement.SizeAllocated (System.Double width, System.Double height) [0x00000] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\VisualElement.cs:629 at Xamarin.Forms.Layout+<>c.<OnChildMeasureInvalidated>b__39_0 () [0x00080] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\Layout.cs:332 at Foundation.NSAsyncActionDispatcher.Apply () [0x00000] in /Users/builder/data/lanes/3969/44931ae8/source/xamarin-macios/src/Foundation/NSAction.cs:163 at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr) at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Users/builder/data/lanes/3969/44931ae8/source/xamarin-macios/src/UIKit/UIApplication.cs:79 at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Users/builder/data/lanes/3969/44931ae8/source/xamarin-macios/src/UIKit/UIApplication.cs:63 at MusiDownPortable.iOS.Application.Main (System.String[] args) [0x00008] in /Users/steebono/SourceTree/musidown/MusiDownPortable/MusiDownPortable/MusiDownPortable.iOS/Main.cs:17

Sometimes scroll works but when I try to reload list I have this exception:

Second StackTrace:

at Xamarin.Forms.Grid.GetLastAutoColumn (Xamarin.Forms.BindableObject child) [0x00016] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\GridCalc.cs:657 at Xamarin.Forms.Grid.ExpandLastAutoColumnIfNeeded (System.Double width, System.Boolean expandToRequest) [0x00024] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\GridCalc.cs:331 at Xamarin.Forms.Grid.MeasureGrid (System.Double width, System.Double height, System.Boolean requestSize) [0x0013a] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\GridCalc.cs:520 at Xamarin.Forms.Grid.LayoutChildren (System.Double x, System.Double y, System.Double width, System.Double height) [0x0000e] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\GridCalc.cs:17 at Xamarin.Forms.Layout.UpdateChildrenLayout () [0x000c7] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\Layout.cs:229 at Xamarin.Forms.Layout.OnSizeAllocated (System.Double width, System.Double height) [0x0000f] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\Layout.cs:194 at Xamarin.Forms.VisualElement.SizeAllocated (System.Double width, System.Double height) [0x00000] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\VisualElement.cs:629 at Xamarin.Forms.Layout+<>c.<OnChildMeasureInvalidated>b__39_0 () [0x00080] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\Layout.cs:332 at Foundation.NSAsyncActionDispatcher.Apply () [0x00000] in /Users/builder/data/lanes/3969/7beaef43/source/xamarin-macios/src/Foundation/NSAction.cs:163 at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr) at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Users/builder/data/lanes/3969/7beaef43/source/xamarin-macios/src/UIKit/UIApplication.cs:79 at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Users/builder/data/lanes/3969/7beaef43/source/xamarin-macios/src/UIKit/UIApplication.cs:63 at MusiDownPortable.iOS.Application.Main (System.String[] args) [0x00008] in /Users/steebono/SourceTree/musidown/MusiDownPortable/MusiDownPortable/MusiDownPortable.iOS/Main.cs:17

XAML Code:

<ListView x:Name="listView" ItemSelected="OnItemSelected" IsVisible="False" HasUnevenRows="False" RowHeight="50" IsPullToRefreshEnabled="True" Refreshing="mySongs_OnRefreshing"> <x:Arguments> <ListViewCachingStrategy>RecycleElement</ListViewCachingStrategy> </x:Arguments> <ListView.ItemTemplate> <DataTemplate> <ViewCell> <ViewCell.ContextActions> <MenuItem Clicked="mySongDelete_OnClicked" CommandParameter="{Binding .}" Text="Delete" IsDestructive="True" /> </ViewCell.ContextActions> <Grid> <Grid.RowDefinitions> <RowDefinition Height="50" /> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="5" /> <ColumnDefinition Width="35" /> <ColumnDefinition Width="*" /> <ColumnDefinition Width="35" /> <ColumnDefinition Width="5" /> </Grid.ColumnDefinitions> <ff:CachedImage Source="{Binding FavoriteIcon}" CacheDuration="1" RetryCount="1" Aspect="AspectFit" HorizontalOptions="StartAndExpand" Grid.Row="0" Grid.Column="1"> <ff:CachedImage.GestureRecognizers> <TapGestureRecognizer Tapped="onClick_Favorite"/> </ff:CachedImage.GestureRecognizers> </ff:CachedImage> <Label Text="{Binding Title}" VerticalOptions="CenterAndExpand" HorizontalOptions="CenterAndExpand" VerticalTextAlignment="Center" HorizontalTextAlignment="Center" LineBreakMode="TailTruncation" FontSize="Medium" Grid.Row="0" Grid.Column="2" /> <ff:CachedImage Source="{Binding MenuIcon}" CacheDuration="1" RetryCount="1" Aspect="AspectFit" HorizontalOptions="EndAndExpand" Grid.Row="0" Grid.Column="3"> <ff:CachedImage.GestureRecognizers> <TapGestureRecognizer Tapped="onClick_Menu"/> </ff:CachedImage.GestureRecognizers> </ff:CachedImage> </Grid> </ViewCell> </DataTemplate> </ListView.ItemTemplate> </ListView>

C# Code:

Inside OnAppearing():

`

// Other code here

listView.ItemSource = _myListItems;

// Other code here

`

My List is declared as:

`

private ObservableCollection<MyItemEntry> _myListItems = new ObservableCollection<MyItemEntry>();

`

MyItemEntry object is a class derived from INotifyPropertyChanged

I have an event that load and reload the list if needed:

`

        // Other code here

        // Start async operation
                Task.Run(() =>
                {
                    // Clear List
                    Device.BeginInvokeOnMainThread(() =>
                    {
                        if (_myListItems.Any()) _myListItems.Clear();
                    });
                    // Get refreshed list.
                    var myList = DependencyService.Get<IItemHandler>().ReadItem;

                    if (myList.Any())
                    {
                        Device.BeginInvokeOnMainThread(() =>
                        {
                            foreach (var itemDataEntry in myList)
                            {
                var menuIcon = "Menu100.png";
                                var favoriteIcon = itemDataEntry.Favorite ? "Favfill.png" : "Fav100.png";
                                _myListItems.Add(new MyItemEntry
                                {
                                    FavoriteIcon = favoriteIcon,
                                    MenuIcon = menuIcon,
                                    Title = decSong
                                });
                            }
                            if (_mySongsItems.Any())
                            {
                                Device.BeginInvokeOnMainThread(() =>
                                {
                                    listView.IsVisible = true;
                                    loadingIndicator.IsVisible = false;
                                    loadingIndicator.IsRunning = false;
                                    layoutDataInfo.IsVisible = false;
                                    lbDataInfo.IsVisible = false;
                                });
                            }
                            else
                            {
                                Device.BeginInvokeOnMainThread(() =>
                                {
                                    listView.IsVisible = false;
                                    loadingIndicator.IsVisible = false;
                                    loadingIndicator.IsRunning = false;
                                    layoutDataInfo.IsVisible = true;
                                    imgDataInfo.IsVisible = true;
                                    lbDataInfo.IsVisible = true;
                                });
                            }
                        });
                    }
                    else
                    {
                        Device.BeginInvokeOnMainThread(() =>
                        {
                            listView.IsVisible = false;
                            loadingIndicator.IsVisible = false;
                            loadingIndicator.IsRunning = false;
                            layoutDataInfo.IsVisible = true;
                            imgDataInfo.IsVisible = true;
                            lbDataInfo.IsVisible = true;
                        });
                    }
                });

// Other code here for update list if needed

`

This codes on Android work perfectly. On iOS this codes work perfectly but if i try to scroll the list, I have that Exception.

A important thing is that this Event do not fire when I scroll the List.
I think that my code is not the cause of this Exception, because this happend only if I scroll
If I open the page and after do nothing, all work perfectly. I do not manage in any way scrolling or similar.

I have viewed the code of Xamarin Libraries and seems That Grid.ColumnDefinitions at some point became null.

First StackTrace say:

at Xamarin.Forms.Grid.CalculateAutoCells (System.Double width, System.Double height) [0x00357] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\GridCalc.cs:144

In this line there is a for cycle:

for (var i = 0; i < _columns.Count; i++)

Second StackTrace say:

at Xamarin.Forms.Grid.CalculateAutoCells (System.Double width, System.Double height) [0x00357] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\GridCalc.cs:657

In this line there is a if with same variable of first stacktrace:
if (_columns[i].Width.IsAuto)

so I think that the null reference exception is caused by _columns var.
As you can see in my xaml code I have set ColumnDefinitions.

This error happens when the list has already been created and displayed so.. someone set this to null at some point or Layout.UpdateChildrenLayout fails to get ColumnDefinitions value?

Another observation is that I set ItemSource of listView inside OnAppearing method; when I reload page, I clear my list object and I re-insert all updated items to list. But I think that this is not a problem because my list's items derived from INotifyPropertyChanged and my list is a ObservableCollecion list.

Xamarin Mac Env: last version iOS: 10.1 Xamarin Forms: 2.3.3.168 / 2.3.3.180 (Tried both)

Sorry for my english.

Thanks,
Stefano


Authentication and security

$
0
0

Hi,

I have a Xamarin App, I can login with Facebook auth, but I also wish to add email+password authentication.

Here is how it work now :smile:
1 - Login is based on Facebook, I receive a "token" back, and store it locally in a "AccountStore"
2 - I connect to my CosmosDB directly, but also on a Azure storage directly, the connection string are hardcoded into the app code.
The same for the other Azure services, like search, storage etc...

So, I have a few questions:

1 - how do I add email + password authentication, I need to register/login/forget password features, but also I need a token back !
I have read that "Mobile App Services" are dead now ! So, how can I do ?

2 - I'm logged into my mobile app, but I connect directly to the CosmosDB, it is insecure, right ?
Is there a way to connect to the azure service wth my token by example ? Or there is another way to do ?
I don't want to put the "server connection string + password" in the mobile app. How can I do ?

Thanks

How to do a simple DataBind

$
0
0

Hi,

I would like to bind an object with its properties to a StackLayout inside my ContentPage.
So basically I have an object with two properties Name and Lastname that is a class property inside my Page.xaml.cs:

I tried different ways to bind it, but all causes the application to just close/crash. So lets say this is my incorrect data-bind implementation:

//Stacklayout inside XAML
<StackLayout x:Name="TestLayout" BindingContext="{Data}">
    <Label Text="{Binding Name}"/>
    <Label Text="{Binding Lastname}"/>
</StackLayout>

//My object
public class MyObject : INotifyPropertyChanged
{
    public event PropertyChangedEventHandler PropertyChanged;
    public string Name
    {
        get
        {
            return Name;
        }
        set
        {
            Name = value;
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(nameof(Name)));
            }
        }
    }
    public string Lastname
    {
        get
        {
            return Lastname;
        }
        set
        {
            Lastname = value;
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(nameof(Lastname)));
            }
        }
    }

    public MyObject(string name, string lastname)
    {
        Name = name;
        Lastname = lastname;
    }
}

//My page
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class MyPage : ContentPage
{
    private MyObject Data;
    public Unloading(string env, string username, string name, string call, PageOptions options)
    {
        InitializeComponent();
        Data = new MyObject("John", "Doe");
    }
}

How do I need to set BindingContext in order for it to work?

BR,
Denis

Label and \n

$
0
0

Hi,

For a Label, Text="A\nB" doesn' t display A on a line and B on a new line but "A\nB". How come?
the doc says to use \n for new lines so I'm lost.
Tks.

François

Button Circle works fine on APi 27 but not the same as api 22

$
0
0

HI ,
I'm using Plugins.Forms.ButtonCircle to create a Pin Page , after creating the view , it was working fine on api 27 , but when i grabbed my friend 5.1 android phone , it showed me something different and I can't understand why .

With pictures you can see the difference .
ps: the 4 buttons on top are :

IsEnabled="False"


here is My code

    <ContentPage.Resources>
        <ResourceDictionary>
            <Style x:Key="buttonStyle" TargetType="Button">
                <Setter Property="HeightRequest" Value="50" />
                <Setter Property="WidthRequest" Value="50" />
                <Setter Property="BorderRadius" Value="50" />
                <Setter Property="BorderColor" Value="White" />

                <Setter Property="BackgroundColor" Value="#3897F0" />
                <Setter Property="TextColor" Value="White" />
                <Setter Property="HorizontalOptions" Value="Center" />
                <Setter Property="FontSize" Value="20" />
            </Style>


            <Style x:Key="buttonStylecode" TargetType="Button">
                <Setter Property="HeightRequest" Value="50" />
                <Setter Property="WidthRequest" Value="50" />
                <Setter Property="BorderRadius" Value="50" />
                <Setter Property="BorderColor" Value="White" />

                <Setter Property="BackgroundColor" Value="Gray" />
                <Setter Property="TextColor" Value="White" />
                <Setter Property="HorizontalOptions" Value="Center" />
                <Setter Property="FontSize" Value="20" />
            </Style>
        </ResourceDictionary>
    </ContentPage.Resources>



    <Grid Margin="40">
        <Grid.RowDefinitions>
            <RowDefinition Height="1*"/>
            <RowDefinition Height="1*"/>
            <RowDefinition Height="3*"/>
            <RowDefinition Height="1*"/>

        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>

        <Label Text="Enter your Pin" Grid.Row="0" Grid.ColumnSpan="3" HorizontalOptions="CenterAndExpand"
               Font="20" TextColor="Black"  FontAttributes="Bold"></Label>

        <!--<Label Text="Data here" TextColor="Black" Grid.Row="1" Grid.ColumnSpan="3" BackgroundColor="Red"></Label>-->

        <Grid Grid.Row="1" Grid.ColumnSpan="3" ColumnSpacing="0">
            <Grid.RowDefinitions>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>



            <local:CircleButton  Text="" Grid.Row="0" Grid.Column="1" BorderThickness="3" Style="{StaticResource buttonStylecode}" IsEnabled="False"/>
            <local:CircleButton   Text="" Grid.Row="0" Grid.Column="2" BorderThickness="3" Style="{StaticResource buttonStylecode}" IsEnabled="False"/>
            <local:CircleButton  Text="" Grid.Row="0" Grid.Column="3" BorderThickness="3" Style="{StaticResource buttonStylecode}" IsEnabled="False"/>
            <local:CircleButton  Text="" Grid.Row="0" Grid.Column="4" BorderThickness="3" Style="{StaticResource buttonStylecode}" IsEnabled="False"/>
        </Grid>




        <Grid Grid.Row="2" Grid.RowSpan="2"  Grid.ColumnSpan="3" RowSpacing="0" >
            <Grid.RowDefinitions>
                <RowDefinition Height="*"/>
                <RowDefinition Height="*"/>
                <RowDefinition Height="*"/>
                <RowDefinition Height="*"/>

            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="*"/>

            </Grid.ColumnDefinitions>

            <local:CircleButton 
                    Text="1"
                    Grid.Row="0" Grid.Column="1"
                    BorderThickness="3" Style="{StaticResource buttonStyle}">
            </local:CircleButton>

            <!--<Button Grid.Row="0" Grid.Column="0" BackgroundColor="Accent" Text="1"></Button>-->

                    <local:CircleButton   Text="2" Grid.Row="0" Grid.Column="2" BorderThickness="3" Style="{StaticResource buttonStyle}" />


                    <!--<Button></Button>-->
            <local:CircleButton  Grid.Row="0" Grid.Column="3"  Text="3" BorderThickness="3" Style="{StaticResource buttonStyle}"></local:CircleButton>


            <local:CircleButton  Grid.Row="1" Grid.Column="1"  Text="4" BorderThickness="3" Style="{StaticResource buttonStyle}"></local:CircleButton>
            <local:CircleButton  Grid.Row="1" Grid.Column="2"  Text="5" BorderThickness="3" Style="{StaticResource buttonStyle}"></local:CircleButton>
            <local:CircleButton  Grid.Row="1" Grid.Column="3"  Text="6" BorderThickness="3" Style="{StaticResource buttonStyle}"></local:CircleButton>

            <local:CircleButton Grid.Row="2" Grid.Column="1"  Text="7" BorderThickness="3" Style="{StaticResource buttonStyle}"></local:CircleButton>
            <local:CircleButton  Grid.Row="2" Grid.Column="2"  Text="8" BorderThickness="3" Style="{StaticResource buttonStyle}"></local:CircleButton>
            <local:CircleButton  Grid.Row="2" Grid.Column="3"  Text="9" BorderThickness="3" Style="{StaticResource buttonStyle}"></local:CircleButton>

            <local:CircleButton  Grid.Row="3" Grid.Column="1" Text="del" BorderThickness="3" Style="{StaticResource buttonStyle}"></local:CircleButton>
            <local:CircleButton  Grid.Row="3" Grid.Column="2" Text="0" BorderThickness="3" Style="{StaticResource buttonStyle}"></local:CircleButton>
            <local:CircleButton  Grid.Row="3" Grid.Column="3"  Text="Ok" BorderThickness="3" Style="{StaticResource buttonStyle}"></local:CircleButton>




        </Grid>
        <Label Text="Cancel" TextColor="Black" Grid.Row="4" Margin="20" Grid.ColumnSpan="3" HorizontalOptions="Center" VerticalOptions="End"></Label>

    </Grid>

Checkbox with Xamarin.Forms

$
0
0

Hi everyone, I have been using Checkbox from Xlabs for a long time but I'm having trouble with it, since I can't change the color of the checked box.
The problem is that this color is almost the same as the color of selected row in ListView (and I can't change that either).

I have tried using the InputKit library, but can't install it from nuget, since it doesn't target my PCL profile.
Is there any simple checkbox implementation out there that is worth using?

LoginPage with FreshMVVM ?

$
0
0

Hello,

what is the best way to implement a Login page with FreshMVVM ?

Any sample or suggestion ?

Thank you

Marco

How to create tables with borders?

$
0
0

How do you create tables with borders in Xamarin.Forms. For me it's kinda funny that Xamarin.Forms has Grid control but you CANNOT define borders for this grid.

Maybe there are some plugins which have tables with borders implemented?


Setting up string format based on if statement.

$
0
0

Is it possible to setup string format inside of a view model based on if statement?

Example:

public decimal DiscOff
{
private set { }
get
{
if(offer.DiscAmountOff != 0)
{
return offer.DiscAmountOff;
}
else
{
return offer.DiscPercentOff;
}
}
}

I want to put $ into the string format if Binding DiscOff returns DiscAmountOff and % if DiscOff returns DiscPercentOff.

CrossMedia works in Debug but not in Release for UWP - error msg about onecore(??)

$
0
0

Below is a snippet of my code. Each of the Debug.WriteLine output that starts with a "->" is to indicate the echoing of what code is about to be run. That is followed by an error message that the system produces that starts with either "onecore" or "onecoreuap". In this way it is easy to see the code and the message that it produces.

I looked up onecoreuap and this MS site
https://msdn.microsoft.com/en-us/library/windows/desktop/mt654040%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396
indicates that "OneCoreUap.lib ... provides the exports for the subset of Win32 APIs that are common to all Windows 10 devices that support the Universal Windows Platform (UWP)."
However, a note at the end says:
"**Important **Windows Store apps should not use OneCoreUap.lib but need to use WindowsApp.lib instead."

1) how can I fix this?
2) how does that app get access to "onecore" or "onecoreuap" (when I do not want it and did not ask for it)?
3) how do I link in to "WindowsApp.lib instead" or do I even need it? (I tried through references in the UWP project)

Here is my code:
`

  Debug.WriteLine("->mediaFile = await CrossMedia.Current.PickPhotoAsync(new PickMediaOptions");
  mediaFile = await CrossMedia.Current.PickPhotoAsync(new PickMediaOptions
  {
      PhotoSize = Plugin.Media.Abstractions.PhotoSize.Small,
  });
  IFolder baseFolder = FileSystem.Current.LocalStorage;
  IFolder picFolder = null;

// The following gets a path for the folder to contain the picture
picFolder = await Util.GetPicPath(baseFolder);

Debug.WriteLine("->IFile newFile = await picFolder.CreateFileAsync(newFileName, CreationCollisionOption.GenerateUniqueName);" );
IFile newFile = await picFolder.CreateFileAsync(newFileName, CreationCollisionOption.GenerateUniqueName);

newFilePath = newFile.Path;

Debug.WriteLine("->using (Stream sWriter = mediaFile.GetStream())");
using (Stream sWriter = mediaFile.GetStream())
{
    Debug.WriteLine("-> using (Stream stream = await newFile.OpenAsync(PCLStorage.FileAccess.ReadAndWrite))");
    using (Stream stream = await newFile.OpenAsync(PCLStorage.FileAccess.ReadAndWrite))  
    {
        Debug.WriteLine("->await sWriter.CopyToAsync(stream);");
        await sWriter.CopyToAsync(stream);
    }
}


//==================================

`

Here is the output that I get:

pickPhoto
->mediaFile = await CrossMedia.Current.PickPhotoAsync(new PickMediaOptions
onecore\com\combase\inc\comcataloghelpers.hpp(64)\combase.dll!76A58550: (caller: 76A582E0) ReturnHr(5) tid(59b4) 80040154 Class not registered

->IFile newFile = await picFolder.CreateFileAsync(newFileName, CreationCollisionOption.GenerateUniqueName);
onecoreuap\shell\windows.storage\dataaccess.cpp(4237)\windows.storage.dll!74610A1F: (caller: 746106BB) ReturnHr(1) tid(5904) 80004001 Not implemented

->using (Stream sWriter = mediaFile.GetStream())
onecoreuap\shell\windows.storage\dataaccess.cpp(3823)\windows.storage.dll!745E00EA: (caller: 745DF9E4) ReturnHr(2) tid(2da4) 80004001 Not implemented
onecore\com\combase\inc\comcataloghelpers.hpp(64)\combase.dll!76A58550: (caller: 76A582E0) ReturnHr(6) tid(65b0) 80040154 Class not registered
onecore\com\combase\inc\comcataloghelpers.hpp(64)\combase.dll!76A58550: (caller: 76A582E0) ReturnHr(7) tid(65b0) 80040154 Class not registered
onecore\com\combase\inc\comcataloghelpers.hpp(64)\combase.dll!76A58550: (caller: 76A582E0) ReturnHr(8) tid(65b0) 80040154 Class not registered

-> using (Stream stream = await newFile.OpenAsync(PCLStorage.FileAccess.ReadAndWrite))
onecoreuap\shell\windows.storage\dataaccess.cpp(3823)\windows.storage.dll!745E00EA: (caller: 745DF9E4) ReturnHr(3) tid(2da4) 80004001 Not implemented
onecore\com\combase\inc\comcataloghelpers.hpp(64)\combase.dll!76A58550: (caller: 76A582E0) ReturnHr(9) tid(65b0) 80040154 Class not registered

->await sWriter.CopyToAsync(stream);

Done pickPhoto

Environment:
Visual Studio 2017 v 15.5.4
Xam.Plugin.Media v 3.1.3
Xamarin.Forms v 2.4.0.280 (because I can not get the app to work with higher versions yet)
Xamarin.FFImageLoading v2.3.4
and many more plugins.

Any suggestions and insight are much appreciated.

Regards, Will

Opening pdf on android device error: file exposed beyond app through intent.getdata()

$
0
0

In my application I download the pdf from an API and store the file on the local file system. Then I try to open the pdf file with the built in viewer of the user. The next message appear:
*.pdf file exposed beyond app through intent.getdata().

 public static void OpenPDF(Context context, string filePath)
        {            
            //Open it up
            Android.Net.Uri pdfPath = Android.Net.Uri.FromFile(new Java.IO.File(filePath));
            Intent intent = new Intent(Intent.ActionView);
            intent.SetDataAndType(pdfPath, "application/pdf");
            intent.SetFlags(ActivityFlags.GrantReadUriPermission);
            intent.SetFlags(ActivityFlags.NewTask);
            intent.SetFlags(ActivityFlags.ClearWhenTaskReset);
            context.StartActivity(intent);
        }

Am i missing something?

Navigation in Maps possible in XF?

$
0
0

Hi,
I want to create a mobile app using Xamarin.Forms, is it possible to set map navigation in it. Live example is UBER. Once we set pickup and destination it will navigate us to the destination. I want something like that , is it possible to achieve it in XF.

implement swager with xamarin forms

$
0
0

how i could generate api call and models automaticcly from swager with xamarin forms .
the api is oauth 2 with java backend if thereis any plugins / tutorial for handling it in xamarin will be great

Xamarin Live Player vs Gorilla Player

$
0
0

Can someone tell me what is better at the current moment? Xamarin Live Player is official, but still in development. Gorilla player seems more stable. Did you test them both so you can tell me the differences?

Handling "OnStop" Cleanup On iOS and Cross-Platform

$
0
0

I have a audio player (Cross Media Manager) that displays in the Status/Notification Bar anytime audio is played. But if you close the app mid-play of an audio file, the status/notification item remains.

On android I can do cleanup stuff in the OnPause/OnStop/OnDestroy methods.

But what about iOS? Since I'm not using any iOS views (it's all PCL)... I'm unsure of how to deallocate this stuff when the app closes.

NOTE: I've tried putting the cleanup in the OnSleep method of App.cs but it didn't work. The notification bar entry remained.

Here's my code for Android.

        protected override void OnDestroy()
        {
            audioCleanup();
            base.OnDestroy();
        }

        protected override void OnPause()
        {
            audioCleanup();
            base.OnPause();
        }

        protected override void OnStop()
        {
            audioCleanup();
            base.OnStop();
        }

        protected void audioCleanup()
        {
            if (CrossMediaManager.Current.AudioPlayer.Status != Plugin.MediaManager.Abstractions.Enums.MediaPlayerStatus.Stopped)
                CrossMediaManager.Current.AudioPlayer.Stop();


            if (CrossMediaManager.Current.MediaNotificationManager != null)
            {
                CrossMediaManager.Current.MediaNotificationManager.StopNotifications();
            }
        }
    }



FlexLayout Improvements

$
0
0

I was hoping to use the new FlexLayout control to display data in a flowing grid (left to right and then down). The new control seems interesting but is missing some basic features and I was wondering if there are any thoughts on improving the control in upcoming releases.

I would suggest the following features and would hope that the community adds or votes on this discussion.

ItemsSource (bind a list of items to the layout)

DataTemplate

MaxRowsOrColumns. Set the maximum row or column count (depending on Direction) before another row/column is added.

Thank you.

java.lang.IllegalArgumentException

$
0
0

Hello Guys,

I have an app built on Xamarin form cross-platform. Currently, Andriod build has a crash. At this moment it happens only on Samsung Galaxy S5 (kltevzw), Android 5.0
I can regenerate it and it happens randomly. Below is the crash log I can find from the Play store.

java.lang.IllegalArgumentException:
at android.view.ViewGroup.offsetRectBetweenParentAndChild (ViewGroup.java:5191)
at android.view.ViewGroup.offsetDescendantRectToMyCoords (ViewGroup.java:5128)
at android.view.ViewRootImpl.scrollToRectOrFocus (ViewRootImpl.java:2978)
at android.view.ViewRootImpl.draw (ViewRootImpl.java:2647)
at android.view.ViewRootImpl.performDraw (ViewRootImpl.java:2577)
at android.view.ViewRootImpl.performTraversals (ViewRootImpl.java:2169)
at android.view.ViewRootImpl.doTraversal (ViewRootImpl.java:1180)
at android.view.ViewRootImpl$TraversalRunnable.run (ViewRootImpl.java:6563)
at android.view.Choreographer$CallbackRecord.run (Choreographer.java:777)
at android.view.Choreographer.doCallbacks (Choreographer.java:590)
at android.view.Choreographer.doFrame (Choreographer.java:560)
at android.view.Choreographer$FrameDisplayEventReceiver.run (Choreographer.java:763)
at android.os.Handler.handleCallback (Handler.java:739)
at android.os.Handler.dispatchMessage (Handler.java:95)
at android.os.Looper.loop (Looper.java:145)
at android.app.ActivityThread.main (ActivityThread.java:5835)
at java.lang.reflect.Method.invoke (Native Method)
at java.lang.reflect.Method.invoke (Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1194)

Any idea?

Thanks
Sid

Sample Animation project is not working in specific android device

$
0
0

Hello,

I'm making iOS & Android App using Xamarin forms.

mostly my app is working iOS & Android devices. And my test phones are Galaxy S9, S6, Shaomi Mi X6. S6 and Mi X6 is working. but In Galaxy S9, Animation not working. (ex. Rotaion animation looks like it's still there & translation animation looks like it has moved th the last location)

I thought i had a problem with my source code. However, It does not work with the example source code(animation/basic/) that is provided by default.

How do i resolve this issue??

The log at the bottom is the log of the animation in the example source code.

[Logs]
10-26 09:51:49.210: D/InputReader(4796): Input event(3): value=1 when=47557165683000
10-26 09:51:49.211: D/InputReader(4796): Input event(3): value=1 when=47557165683000
10-26 09:51:49.211: I/InputReader(4796): Touch event's action is 0x0 (deviceType=0) [pCnt=1, s=0.25476 ] when=47557165683000
10-26 09:51:49.212: I/InputDispatcher(4796): Delivering touch to (5273): action: 0x4, toolType: 1
10-26 09:51:49.212: I/InputDispatcher(4796): Delivering touch to (5273): action: 0x4, toolType: 1
10-26 09:51:49.212: I/InputDispatcher(4796): Delivering touch to (21156): action: 0x0, toolType: 1
10-26 09:51:49.214: D/ViewRootImpl@8730f32MainActivity: ViewPostIme pointer 0
10-26 09:51:49.285: D/InputReader(4796): Input event(3): value=0 when=47557240773000
10-26 09:51:49.285: D/InputReader(4796): Input event(3): value=0 when=47557240773000
10-26 09:51:49.286: I/InputReader(4796): Touch event's action is 0x1 (deviceType=0) [pCnt=1, s=] when=47557240773000
10-26 09:51:49.286: I/InputDispatcher(4796): Delivering touch to (21156): action: 0x1, toolType: 1
10-26 09:51:49.294: D/ViewRootImpl@8730f32MainActivity: ViewPostIme pointer 1
10-26 09:51:49.341: I/zygote64(21156): Do full code cache collection, code=119KB, data=107KB
10-26 09:51:49.343: I/zygote64(21156): After code cache collection, code=116KB, data=78KB
10-26 09:51:49.522: E/adbd(30913): recv: OPEN 00000043 00000000 000c:73 68 65 6C 6C 3A 70 73 20 2D 41 00
10-26 09:51:49.522: E/adbd(30913): service_to_fd: shell:ps -A
10-26 09:51:50.527: W/svoiceapi(6556): RCF Server getThreadCount : 1
10-26 09:51:50.528: W/svoiceapi(6556): RCF Server notifyReady
10-26 09:51:50.528: W/svoiceapi(6556): RCF Server shouldStop : 0
10-26 09:51:50.528: W/svoiceapi(6556): RCF Server cycle timeout : 1000
10-26 09:51:50.528: W/svoiceapi(6556): RCF Server shouldStop : 0
10-26 09:51:50.528: W/svoiceapi(6556): RCF Server getThreadCount : 1
10-26 09:51:50.528: W/svoiceapi(6556): RCF Server notifyReady
10-26 09:51:50.528: W/svoiceapi(6556): RCF Server shouldStop : 0
10-26 09:51:50.528: W/svoiceapi(6556): RCF Server cycle timeout : 1000
10-26 09:51:50.528: W/svoiceapi(6556): RCF Server shouldStop : 0
10-26 09:51:50.671: E/adbd(30913): recv: OPEN 00000044 00000000 000c:73 68 65 6C 6C 3A 70 73 20 2D 41 00
10-26 09:51:50.671: E/adbd(30913): service_to_fd: shell:ps -A

How can use mysql database of php site to xamarin app

$
0
0
Hi
I want to use mysql from the site to app. How can i do it?
Is it difficult?
I dont know any about php and mysql.

Can not Build AdHoc or AppStore version

$
0
0

Hi,

I have a problem when I try to build an AdHoc or AppStore version of my iOS App.
The Simulator works with no problem.

I use the latest version of Visual Studio 2017 and I connect to a Mac (High Sierra) with the latest version of XCode and Visual Studio 2017.
I have tried two different Mac (High Sierra) computers and the same problem happens.

When I look at the log after the failed build the following message is repeated:

Xamarin.VisualStudio.IOS.Commands.iOSCommandExtension|Error|0|Could not determine if any of the solution projects are Xamarin.iOS ones. 'Show IPA File on Build Server' menu option will remain disabled.
System.ArgumentNullException: Value cannot be null.
Parameter name: path2
at System.IO.Path.Combine(String path1, String path2)
at Xamarin.VisualStudio.IOS.Commands.ShowIPAFileInFinder.GetIpaLocalPath() in E:\A_work\157\s\src\Core\VisualStudio.IOS\Commands\ShowIPAFileInFinder.cs:line 123
at Xamarin.VisualStudio.IOS.Commands.ShowIPAFileInFinder.QueryStatus(IMenuCommand command) in E:\A_work\157\s\src\Core\VisualStudio.IOS\Commands\ShowIPAFileInFinder.cs:line 69
System.Net.Mqtt.Sdk.ClientPacketListener|Warning|0|Client vs12072Patu - No packet has been sent in 30 seconds. Sending Ping to Server to maintain Keep Alive
System.Net.Mqtt.Sdk.ClientPacketListener|Information|0|Client vs12072Patu - Dispatching PingResponse message to flow PingFlow
System.Net.Mqtt.Sdk.ClientPacketListener|Information|0|Client vs12072Patu - Dispatching Publish message to flow PublishReceiverFlow and topic xma/client-status
System.Net.Mqtt.Sdk.MqttClientImpl|Information|0|Client vs12072Patu - An application message for topic xma/client-status was received

Viewing all 77050 articles
Browse latest View live


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