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

Bug: Xamarin.Froms ControlTemplate with ToolbarItem does not work

$
0
0

Description
Hello.

Basic Setup: I want to have a Xamarin.Forms.ToolbarItem and a Xamarin.Forms.ControlTemplate in a ContentPage with a ViewModel. The ToolbarItem has a Command which should be executed on Tap.

Problem: The ToolbarItem.Command has a Binding to the ViewModel.Command which does not work.
When I start and click on the ToolbarItem it does not work.

Can someone tell me if I am missing something here, or if this is a real issue?
I am not very experienced with Bug reports so if I need to add/change something pleas tell me.

Steps to Reproduce
Create .net standard Project with Prism.Template
Choose Android Project for execution
Create a new Page with new Item Prism Content Page
Navigate at startup to that page
App.xaml.cs

await NavigationService.NavigateAsync("NavigationPage/DummyPage");

Insert the Code
DummTestPage

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http:  //xamarin.com/schemas/2014/forms"
             xmlns:x="http:  //schemas.microsoft.com/winfx/2009/xaml"
             xmlns:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms"
             prism:ViewModelLocator.AutowireViewModel="True"
             x:Class="TestNetCore.Views.DummyPage">
    <ContentPage.ControlTemplate>
        <ControlTemplate>
            <StackLayout>
                <Grid>
                    <BoxView BackgroundColor="Lime" />
                    <Label>I TEST ControlTemplate</Label>
                </Grid>
                <ContentPresenter />
            </StackLayout>
        </ControlTemplate>
    </ContentPage.ControlTemplate>
    <ContentPage.ToolbarItems>
        <ToolbarItem Text="A" Clicked="MenuItem_OnClicked" Command="{Binding ToolbarTappedCommand}"></ToolbarItem>
    </ContentPage.ToolbarItems>
    <StackLayout>
        <Label FontSize="28">I AM AN EMPTY PAGE</Label>
    </StackLayout>
</ContentPage>

DummTestPage.cs

        public partial class DummyPage : ContentPage
    {
        #region Public Constructors

        public DummyPage()
        {
            InitializeComponent();
        }

        #endregion Public Constructors

        #region Private Methods

        private void MenuItem_OnClicked(object sender, EventArgs e)
        {
        }

        #endregion Private Methods
    }

DummyPageViewModel

public class DummyPageViewModel : BindableBase
    {
        #region Public Constructors

        public DummyPageViewModel()
        {
            ToolbarTappedCommand = new NewCommand();
        }

        #endregion Public Constructors

        #region Public Properties

        public ICommand ToolbarTappedCommand { get; set; }

        #endregion Public Properties
    }

    public class NewCommand : ICommand
    {
        #region Public Events

        public event EventHandler CanExecuteChanged;

        #endregion Public Events

        #region Public Methods

        public bool CanExecute(object parameter)
        {
            return true;
        }

        public void Execute(object parameter)
        {
        }

        #endregion Public Methods
    }

Set a Breakpoint to
NewCommand.CanExecute
NewCommand.Execute
MenuItem_OnClicked
Execute Programm

Expected Behavior
Execute NewCommand.CanExecute on startup
Execute NewCommand.Execute on Tap
Execute MenuItem_OnClicked on Tap

Actual Behavior
Execute MenuItem_OnClicked on Tap

Basic Information
Version with issue: Prism Template Pack 2.0.8 | Prism.Unit.Forms 7.0.0.362
Last known good version: -
Xamarin.Forms version: 2.5.0.280555
IDE: VS17 15.6.1
Screenshots
Reproduction Link
What exactly do i need to do here?

Solutions
Removeing the lines in the XAML

xmlns:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms"
prism:ViewModelLocator.AutowireViewModel="True"

Every thing works as expected now
2. Removeing the ControlTemplate in the XMAL

    <ContentPage.ControlTemplate>
        <ControlTemplate>
            <StackLayout>
                <Grid>
                    <BoxView BackgroundColor="Lime" />
                    <Label>I TEST ControlTemplate</Label>
                </Grid>
                <ContentPresenter />
            </StackLayout>
        </ControlTemplate>
    </ContentPage.ControlTemplate>

Works but you dont have a controlTemplate now :(
3. Switching ControlTemplate and ToolbarItems

    <ContentPage.ToolbarItems>
        <ToolbarItem Text="A" Clicked="MenuItem_OnClicked" Command="{Binding ToolbarTappedCommand}"></ToolbarItem>
    </ContentPage.ToolbarItems>
    <ContentPage.ControlTemplate>
        <ControlTemplate>
            <StackLayout>
                <Grid>
                    <BoxView BackgroundColor="Lime" />
                    <Label>I TEST ControlTemplate</Label>
                </Grid>
                <ContentPresenter />
            </StackLayout>
        </ControlTemplate>
    </ContentPage.ControlTemplate>

CanExecute is not called at beginning
And if you set the ControlTemplate as StaticRessouce (which is what I like to do) this does not work
ControlTemplate="{StaticResource BaseControlTemplate}"

Tags
Xamarin.Froms ControlTemplate ToolbarItem Binding not working


Help URGENT!!!! Simple http get....receving exception

$
0
0

To be honest i have dozen app accessing backend api ....its driving me crazy...in fact my boss is not happy at all

i create a blank xamarin forms netstandard 2

var uri = "some url to get";
var client = new HttpClient();
var response = await client.GetAsync(uri);
var text = await response.Content.ReadAsStringAsync();

With this code above in a button handler

Getting exception in GetAsync() line

{System.Net.Http.HttpRequestException: An error occurred while sending the request ---> System.Net.WebException: Error getting response stream (ReadDone2): ReceiveFailure ---> System.Exception: at System.Net.WebConnection.HandleError (System.Net.WebExceptionStatus st, System.Exception e, System.String where) [0x00031] in :0
at System.Net.WebConnection.ReadDone (System.IAsyncResult result) [0x00056] in :0
at System.Net.Sockets.SocketAsyncResult+<>c.b__27_0 (System.Object state) [0x00000] in :0
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem () [0x00015] in :0
at System.Threading.ThreadPoolWorkQueue.Dispatch () [0x00074] in :0
at ObjCRuntime.Runtime.ThreadPoolDispatcher (System.Func1[TResult] callback) [0x00006] in <b7935acd70e343049845d6fd73e5ec44>:0 at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () [0x00009] in <cf9013b38a4e4129bd64785080dd2844>:0 at System.Net.WebConnection.HandleError (System.Net.WebExceptionStatus st, System.Exception e, System.String where) [0x00031] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.0.20/src/Xamarin.iOS/mcs/class/System/System.Net/WebConnection.cs:439 --- End of inner exception stack trace --- at System.Net.HttpWebRequest.EndGetResponse (System.IAsyncResult asyncResult) [0x00059] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.0.20/src/Xamarin.iOS/mcs/class/System/System.Net/HttpWebRequest.cs:1033 at System.Threading.Tasks.TaskFactory1[TResult].FromAsyncCoreLogic (System.IAsyncResult iar, System.Func2[T,TResult] endFunction, System.Action1[T] endAction, System.Threading.Tasks.Task1[TResult] promise, System.Boolean requiresSynchronization) [0x0000f] in <cf9013b38a4e4129bd64785080dd2844>:0 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.0.20/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:152 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00037] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.0.20/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.0.20/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.0.20/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128 at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in :0
at System.Net.Http.HttpClientHandler+d__64.MoveNext () [0x003d3] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.0.20/src/Xamarin.iOS/mcs/class/System.Net.Http/System.Net.Http/HttpClientHandler.cs:402
--- End of inner exception stack trace ---
at System.Net.Http.HttpClientHandler+d__64.MoveNext () [0x0046c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.0.20/src/Xamarin.iOS/mcs/class/System.Net.Http/System.Net.Http/HttpClientHandler.cs:406
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.0.20/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:152
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00037] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.0.20/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.0.20/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.0.20/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <cf9013b38a4e4129bd64785080dd2844>:0 at System.Net.Http.HttpClient+<SendAsyncWorker>d__48.MoveNext () [0x00080] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.0.20/src/Xamarin.iOS/mcs/class/System.Net.Http/System.Net.Http/HttpClient.cs:276 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.0.20/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:152 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00037] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.0.20/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.0.20/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.0.20/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128 at System.Runtime.CompilerServices.TaskAwaiter1[TResult].GetResult () [0x00000] in :0
at App7.MainPage+d__1.MoveNext () [0x00051] in C:\Users\gilbe\source\repos\App7\App7\App7\MainPage.xaml.cs:27 }

Thanks very much

Bug: Xamarin.Froms ControlTemplate with ToolbarItem does not work

$
0
0

Description
Hello.

Basic Setup: I want to have a Xamarin.Forms.ToolbarItem and a Xamarin.Forms.ControlTemplate in a ContentPage with a ViewModel. The ToolbarItem has a Command which should be executed on Tap.

Problem: The ToolbarItem.Command has a Binding to the ViewModel.Command which does not work.
When I start and click on the ToolbarItem it does not work.

Can someone tell me if I am missing something here, or if this is a real issue?
I am not very experienced with Bug reports so if I need to add/change something pleas tell me.

Steps to Reproduce
Create .net standard Project with Prism.Template
Choose Android Project for execution
Create a new Page with new Item Prism Content Page
Navigate at startup to that page
App.xaml.cs

await NavigationService.NavigateAsync("NavigationPage/DummyPage");

Insert the Code
DummTestPage

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http:  //xamarin.com/schemas/2014/forms"
             xmlns:x="http:  //schemas.microsoft.com/winfx/2009/xaml"
             xmlns:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms"
             prism:ViewModelLocator.AutowireViewModel="True"
             x:Class="TestNetCore.Views.DummyPage">
    <ContentPage.ControlTemplate>
        <ControlTemplate>
            <StackLayout>
                <Grid>
                    <BoxView BackgroundColor="Lime" />
                    <Label>I TEST ControlTemplate</Label>
                </Grid>
                <ContentPresenter />
            </StackLayout>
        </ControlTemplate>
    </ContentPage.ControlTemplate>
    <ContentPage.ToolbarItems>
        <ToolbarItem Text="A" Clicked="MenuItem_OnClicked" Command="{Binding ToolbarTappedCommand}"></ToolbarItem>
    </ContentPage.ToolbarItems>
    <StackLayout>
        <Label FontSize="28">I AM AN EMPTY PAGE</Label>
    </StackLayout>
</ContentPage>

DummTestPage.cs

        public partial class DummyPage : ContentPage
    {
        #region Public Constructors

        public DummyPage()
        {
            InitializeComponent();
        }

        #endregion Public Constructors

        #region Private Methods

        private void MenuItem_OnClicked(object sender, EventArgs e)
        {
        }

        #endregion Private Methods
    }

DummyPageViewModel

public class DummyPageViewModel : BindableBase
    {
        #region Public Constructors

        public DummyPageViewModel()
        {
            ToolbarTappedCommand = new NewCommand();
        }

        #endregion Public Constructors

        #region Public Properties

        public ICommand ToolbarTappedCommand { get; set; }

        #endregion Public Properties
    }

    public class NewCommand : ICommand
    {
        #region Public Events

        public event EventHandler CanExecuteChanged;

        #endregion Public Events

        #region Public Methods

        public bool CanExecute(object parameter)
        {
            return true;
        }

        public void Execute(object parameter)
        {
        }

        #endregion Public Methods
    }

Set a Breakpoint to
NewCommand.CanExecute
NewCommand.Execute
MenuItem_OnClicked
Execute Programm

Expected Behavior
Execute NewCommand.CanExecute on startup
Execute NewCommand.Execute on Tap
Execute MenuItem_OnClicked on Tap

Actual Behavior
Execute MenuItem_OnClicked on Tap

Basic Information
Version with issue: Prism Template Pack 2.0.8 | Prism.Unit.Forms 7.0.0.362
Last known good version: -
Xamarin.Forms version: 2.5.0.280555
IDE: VS17 15.6.1
Screenshots
Reproduction Link
What exactly do i need to do here?

Solutions
Removeing the lines in the XAML

xmlns:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms"
prism:ViewModelLocator.AutowireViewModel="True"

Every thing works as expected now
2. Removeing the ControlTemplate in the XMAL

    <ContentPage.ControlTemplate>
        <ControlTemplate>
            <StackLayout>
                <Grid>
                    <BoxView BackgroundColor="Lime" />
                    <Label>I TEST ControlTemplate</Label>
                </Grid>
                <ContentPresenter />
            </StackLayout>
        </ControlTemplate>
    </ContentPage.ControlTemplate>

Works but you dont have a controlTemplate now :(
3. Switching ControlTemplate and ToolbarItems

    <ContentPage.ToolbarItems>
        <ToolbarItem Text="A" Clicked="MenuItem_OnClicked" Command="{Binding ToolbarTappedCommand}"></ToolbarItem>
    </ContentPage.ToolbarItems>
    <ContentPage.ControlTemplate>
        <ControlTemplate>
            <StackLayout>
                <Grid>
                    <BoxView BackgroundColor="Lime" />
                    <Label>I TEST ControlTemplate</Label>
                </Grid>
                <ContentPresenter />
            </StackLayout>
        </ControlTemplate>
    </ContentPage.ControlTemplate>

CanExecute is not called at beginning
And if you set the ControlTemplate as StaticRessouce (which is what I like to do) this does not work
ControlTemplate="{StaticResource BaseControlTemplate}"

Tags
Xamarin.Froms ControlTemplate ToolbarItem Binding not working

Help URGENT!!!! Simple http get....receving exception

$
0
0

To be honest i have dozen app accessing backend api ....its driving me crazy...in fact my boss is not happy at all

i create a blank xamarin forms netstandard 2

var uri = "some url to get";
var client = new HttpClient();
var response = await client.GetAsync(uri);
var text = await response.Content.ReadAsStringAsync();

With this code above in a button handler

Getting exception in GetAsync() line

{System.Net.Http.HttpRequestException: An error occurred while sending the request ---> System.Net.WebException: Error getting response stream (ReadDone2): ReceiveFailure ---> System.Exception: at System.Net.WebConnection.HandleError (System.Net.WebExceptionStatus st, System.Exception e, System.String where) [0x00031] in :0
at System.Net.WebConnection.ReadDone (System.IAsyncResult result) [0x00056] in :0
at System.Net.Sockets.SocketAsyncResult+<>c.b__27_0 (System.Object state) [0x00000] in :0
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem () [0x00015] in :0
at System.Threading.ThreadPoolWorkQueue.Dispatch () [0x00074] in :0
at ObjCRuntime.Runtime.ThreadPoolDispatcher (System.Func1[TResult] callback) [0x00006] in <b7935acd70e343049845d6fd73e5ec44>:0 at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () [0x00009] in <cf9013b38a4e4129bd64785080dd2844>:0 at System.Net.WebConnection.HandleError (System.Net.WebExceptionStatus st, System.Exception e, System.String where) [0x00031] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.0.20/src/Xamarin.iOS/mcs/class/System/System.Net/WebConnection.cs:439 --- End of inner exception stack trace --- at System.Net.HttpWebRequest.EndGetResponse (System.IAsyncResult asyncResult) [0x00059] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.0.20/src/Xamarin.iOS/mcs/class/System/System.Net/HttpWebRequest.cs:1033 at System.Threading.Tasks.TaskFactory1[TResult].FromAsyncCoreLogic (System.IAsyncResult iar, System.Func2[T,TResult] endFunction, System.Action1[T] endAction, System.Threading.Tasks.Task1[TResult] promise, System.Boolean requiresSynchronization) [0x0000f] in <cf9013b38a4e4129bd64785080dd2844>:0 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.0.20/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:152 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00037] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.0.20/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.0.20/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.0.20/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128 at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in :0
at System.Net.Http.HttpClientHandler+d__64.MoveNext () [0x003d3] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.0.20/src/Xamarin.iOS/mcs/class/System.Net.Http/System.Net.Http/HttpClientHandler.cs:402
--- End of inner exception stack trace ---
at System.Net.Http.HttpClientHandler+d__64.MoveNext () [0x0046c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.0.20/src/Xamarin.iOS/mcs/class/System.Net.Http/System.Net.Http/HttpClientHandler.cs:406
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.0.20/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:152
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00037] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.0.20/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.0.20/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.0.20/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <cf9013b38a4e4129bd64785080dd2844>:0 at System.Net.Http.HttpClient+<SendAsyncWorker>d__48.MoveNext () [0x00080] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.0.20/src/Xamarin.iOS/mcs/class/System.Net.Http/System.Net.Http/HttpClient.cs:276 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.0.20/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:152 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00037] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.0.20/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.0.20/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.0.20/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128 at System.Runtime.CompilerServices.TaskAwaiter1[TResult].GetResult () [0x00000] in :0
at App7.MainPage+d__1.MoveNext () [0x00051] in C:\Users\gilbe\source\repos\App7\App7\App7\MainPage.xaml.cs:27 }

Thanks very much

Dynamic items in grid

$
0
0

How can I receive items from REST service as items dynamic in grid like add more rows dynamically to fit items in columns, load more items in the page, I just have a problem with how to do the grid, I can deal with REST but the layout it's the problem

convert java code to xamarin forms

$
0
0

Hi, i am new in xamarin forms and i want to implement image encryption and decryption. I have java code that do the encryption and decryption for the image and i want to convert it to C# that work in xamarin forms and this is my java code can any one covert it to me please.

package imageencryptanddecrypt;

import java.awt.Color;
import java.awt.image.BufferedImage;
import java.io.File;
import java.security.SecureRandom;
import javax.imageio.ImageIO;


public class ImageEncryptAndDecrypt {


   public static void main(String s[]){

    String sPath="picture.jpg";
    String dPath="picture.jpg";
    String password="1234";
   StringBuilder sb=new StringBuilder();
    char st; 
    int value;
    try{
        for (int i = 0; i < password.length(); i++) {
             st=password.charAt(i);
             value=(int)st;
             sb.append(value);
        }
    SecureRandom sr= SecureRandom.getInstance("SHA1PRNG");
    sr.setSeed(sb.toString().getBytes());
    BufferedImage FSImg=ImageIO.read(new File(sPath));  
        for (int w = 0; w < FSImg.getWidth(); w++) {
            for (int h = 0; h < FSImg.getHeight(); h++) {
                Color color=new Color(FSImg.getRGB(w, h));
                Color newColor=new Color(color.getRed()^sr.nextInt(255), color.getGreen()^sr.nextInt(255), color.getBlue()^sr.nextInt(255));
                FSImg.setRGB(w, h, newColor.getRGB());
            }
        }
    System.out.println("Process Completed!!..");
    ImageIO.write(FSImg, "bmp", new File(dPath));
    System.out.println("Wrote to "+dPath);
    }catch(Exception e){
    e.printStackTrace();}
    }

}

Troubles with Gmail authentication

$
0
0

Hello, I'm trying to implement Gmail authentication on my Xamarin Forms app. Searching for solutions I found to libraries which I can use. Implementations both of them turns error to me. First I tried the Xamarin.GooglePlayServices.Auth. I do all which was described in this article: https://causerexception.com/2017/12/03/google-native-login-with-xamarin-forms/ . I do exactly as it was described event set all of my libraries to the same version, but during compilation it throw exception: ImageManager_OnImageLoadedListenerImplementor is not abstract and does not override abstract method onImageLoaded(Uri,Drawable) Then I tried to delete all code which connected with image downloading but still have the same error.
The second version was Xamarin Auth library. I follow Xamarin site https://docs.microsoft.com/en-us/xamarin/xamarin-forms/data-cloud/authentication/oauth#android. It compiles fine, however, it throws Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup I google this error, so I check my Google+ API service was enabled, and scope was correct.
Now I stuck and would be thankful for any help.

is XAML Compilation working in XF 2.3.1.114 - INVALID IL CODE message displayed

$
0
0

We have an issue when we turn on XAML Compilation at the assembly level. The problem occurs in all platforms and only occurs when the application is deployed to an emulator/real device and the application is launched.

The issue/error we receive is one of an INVALID IL CODE

The attached images show the XAML used (Highlighted) that causes the INVALID IL CODE - When we compile without XAMLCOMPILATION - no errors occur and the app runs as intended.

The IL errors for both cases are :

09-05 13:41:16.336 I/MonoDroid( 6261): ---> System.InvalidProgramException: Invalid IL code in ModuleSettings.Views.SettingsFields:InitializeComponent (): IL_01cf: callvirt 0x0a000026

and

09-05 13:53:25.612 I/MonoDroid( 6716): Exception is: InvalidProgramException - Invalid IL code in ModuleSettings.Views.SettingsFields:InitializeComponent (): IL_0254: callvirt 0x0a000034

The FULL XAML that is defined is attached (Note actual production code is stripped out to demonstrate purely the error we receive)


How is ResourceDictionary MergedWith feature meant to work?

$
0
0

I'm tying out the MergedWith feature in ResourceDictionaries in Forms (Xamarin.Forms.2.3.1.111-pre2).

I have specified the main ResourceDictionary in App.xaml like:

<?xml version="1.0" encoding="utf-8"?>
<Application xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:custom="clr-namespace:Demo.Custom.Styles;assembly=Demo.Custom"             
             x:Class="Demo.App">

  <Application.Resources>  
    <ResourceDictionary MergedWith="custom:CustomResources">
      <Style x:Key="TitleBarStyle" TargetType="StackLayout">
        <Setter Property="BackgroundColor" Value="Blue" />
      </Style>
      <Color x:Key="Color_1">Red</Color>
    </ResourceDictionary>
  </Application.Resources>  
</Application>

The dictionary that I am trying to merge (CustomResources) is a xaml file in another portable project as follows:

<?xml version="1.0" encoding="utf-8"?>
<ResourceDictionary xmlns="http://xamarin.com/schemas/2014/forms"
                xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                x:Class="Demo.Custom.Styles.CustomResources">
  <Style x:Key="TitleBarStyle" TargetType="StackLayout">
    <Setter Property="BackgroundColor" Value="Yellow" />
  </Style>
  <Color x:Key="Color_1">Green</Color>
</ResourceDictionary>

When I debug the application, I can see that the dictionaries have merged since Resources.count gives 4 (two resources in each dictionary), but the Keys & Values count is still 2. Looking deeper the keys and values are from the original dictionary. Looking at the Resources.IEnumerator values I can see all 4 resources as key:value pairs confirming that both dictionaries have merged.

This not exactly the way I was expecting merging would work. This is how it is specified in the docs:

"The ResourceDictionary specified as the value of the MergedWith property is merged into the current ResourceDictionary instance. Note that any resources in the current ResourceDictionary that share x:Key attribute values with resources in the ResourceDictionary to be merged, will be replaced."

I thought I would end up with two resources with values from CustomResources.xaml since the x:Keys are the same in both dictionaries. Is this a bug or have I misunderstood something? How am I meant to use dictionary values elsewhere if the merging works like above? I thought I would use them by the key simply as in 'Style="{DynamicResource TitleBarStyle}"' like normally.

How to implement Parallax ListView sticky header view [Xamarin Form iOS and Android]

$
0
0

Hello All,

I want to make Parallax ListView using Xamarin form [iOS and Android]

need parallax banner image and sticky header for the list view.

example like this video www.youtube.com/watch?v=eyWDkwVnYxo

How can I do this?

How to use Firebase cloud services in Xamarin Forms app ?

$
0
0

Hi folks,

should i use separately for sampleApp.droid and sampleApp.ios or is there common code.
thanks in advance.

convert java code to xamarin forms

$
0
0

Hi, i am new in xamarin forms and i want to implement image encryption and decryption. I have java code that do the encryption and decryption for the image and i want to convert it to C# that work in xamarin forms and this is my java code can any one covert it to me please.

package imageencryptanddecrypt;

import java.awt.Color;
import java.awt.image.BufferedImage;
import java.io.File;
import java.security.SecureRandom;
import javax.imageio.ImageIO;


public class ImageEncryptAndDecrypt {


   public static void main(String s[]){

    String sPath="picture.jpg";
    String dPath="picture.jpg";
    String password="1234";
   StringBuilder sb=new StringBuilder();
    char st; 
    int value;
    try{
        for (int i = 0; i < password.length(); i++) {
             st=password.charAt(i);
             value=(int)st;
             sb.append(value);
        }
    SecureRandom sr= SecureRandom.getInstance("SHA1PRNG");
    sr.setSeed(sb.toString().getBytes());
    BufferedImage FSImg=ImageIO.read(new File(sPath));  
        for (int w = 0; w < FSImg.getWidth(); w++) {
            for (int h = 0; h < FSImg.getHeight(); h++) {
                Color color=new Color(FSImg.getRGB(w, h));
                Color newColor=new Color(color.getRed()^sr.nextInt(255), color.getGreen()^sr.nextInt(255), color.getBlue()^sr.nextInt(255));
                FSImg.setRGB(w, h, newColor.getRGB());
            }
        }
    System.out.println("Process Completed!!..");
    ImageIO.write(FSImg, "bmp", new File(dPath));
    System.out.println("Wrote to "+dPath);
    }catch(Exception e){
    e.printStackTrace();}
    }

}

Cancelled Button Event in Search Bar in Xamarin Forms

$
0
0

Can any help me how to trigger an event when cancel button on Search bar is Pressed. I want to refresh the listview when i press the cancel the button

Keyboard property not working on entry renrerer

$
0
0

I have a custom renderer for entry,while adding keyboard property to the XAML then it will not work.

I set keyboard="Numeric" but it shows full keyboard,but unable to type alphabet only numeric key working.so how to show numeric keyboard with entry custom render?

JObject response = JsonConvert.DeserializeObject(json); not working properly.

$
0
0

var json = await httpClient.GetStringAsync(
"https://www.instagram.com/"
//https://www.instagram.com/tmteice/#access_token=7376071860.4a7135d.99d3c8a954d64424889fe17e16b96ee0
);

        JObject response = JsonConvert.DeserializeObject<dynamic>(json);


        var items = response.Value<JArray>("items");

        try
        {

            var instagramItems = new List<InstagramItem>();

            foreach (var item in items)
            {
                var instagramItem = new InstagramItem
                {
                    UserName = item.Value<JObject>("user").Value<string>("username"),
                    FullName = item.Value<JObject>("user").Value<string>("full_name"),
                    ProfilePicture = item.Value<JObject>("user").Value<string>("profile_picture"),
                    LowResolutionUrl = item.Value<JObject>("images").Value<JObject>("low_resolution").Value<string>("url"),
                    StandardResolutionUrl = item.Value<JObject>("images").Value<JObject>("standard_resolution").Value<string>("url"),
                    ThumbnailUrl = item.Value<JObject>("images").Value<JObject>("thumbnail").Value<string>("url"),
                    Text = item.Value<JObject>("caption").Value<string>("text"),
                    CreatedTime = item.Value<JObject>("caption").Value<string>("created_time"),
                    LikesCount = item.Value<JObject>("likes").Value<int>("count"),
                    CommentsCount = item.Value<JObject>("comments").Value<int>("count"),
                };

                instagramItems.Add(instagramItem);
            }

            InstagramItems = instagramItems;
        }
        catch (Exception ex)
        {

        }
    }

    public event PropertyChangedEventHandler PropertyChanged;

    protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
    {
        if (PropertyChanged != null)
        {
            PropertyChanged.Invoke(this, new PropertyChangedEventArgs(propertyName));
        }
    }
}

}


Is possible connect to a specified WIFI in iOS?

$
0
0

I have a SSID and password for a WI-FI and i try to connect it automatically. I have found the solution for Android, but have anyone same solution for iOS?

Creating Round Buttons with centered Image and Label

$
0
0

Hey together,

i'm quite new to xamarin forms and i would like to create some buttons like in the image linked next.

us.v-cdn.net/5019960/uploads/editor/ot/ox4hgakakrig.png

I tried something ike this:

<StackLayout Orientation="Horizontal">
            <Button ContentLayout="Top,-70" 
                    VerticalOptions="EndAndExpand"
                    HorizontalOptions="CenterAndExpand" 
                    Text="Label" 
                    FontSize="20"
                    Image="ic_home_white_72dp.png" 
                    WidthRequest="120" 
                    HeightRequest="120"  
                    BorderRadius="60" 
                    BackgroundColor="#3F51B5" 
                    TextColor="#FFFFFF" />

            <Button x:Name="button_app"
                    ContentLayout="Top,-70" 
                    VerticalOptions="EndAndExpand"
                    HorizontalOptions="CenterAndExpand" 
                    Text="Apps" 
                    FontSize="20"
                    Image="ic_apps_white_72dp.png" 
                    WidthRequest="120" 
                    HeightRequest="120"  
                    BorderRadius="60" 
                    BackgroundColor="#3F51B5" 
                    TextColor="#FFFFFF" />

            <Button ContentLayout="Top,-70" 
                    VerticalOptions="EndAndExpand"
                    HorizontalOptions="CenterAndExpand" 
                    Text="Telefon" 
                    FontSize="20"
                    Image="ic_phone_white_72dp.png" 
                    WidthRequest="120" 
                    HeightRequest="120"  
                    BorderRadius="60" 
                    BackgroundColor="#3F51B5" 
                    TextColor="#FFFFFF" />
            </StackLayout>

This is the output I'm getting
us.v-cdn.net/5019960/uploads/editor/e8/l0j5sqh1lrv1.png

How could i archive that the images in the buttonsare getting centered? Maybe with a custom button?

Unable to notify second device when receive image from blob

$
0
0

I am working a chat application and I am using blob for image store when when I upload a image with button click then receive image doesn't received to another device only sender device showing it.

Upload and Receive code:
using (var memoryStream = new MemoryStream())
{
activityIndicator.IsRunning = true;
file.GetStream().CopyTo(memoryStream);
file.Dispose();
// return memoryStream.ToArray();
uploadedFilename = await AzureStorage.UploadFileAsync(ContainerType.Image, new MemoryStream(memoryStream.ToArray()));
}

            if (!string.IsNullOrWhiteSpace(uploadedFilename))
            {
                var imageData = await AzureStorage.GetFileAsync(ContainerType.Image, uploadedFilename);

                var img = ImageSource.FromStream(() => new MemoryStream(imageData));

                TextContainer.Add(new MessageText { imgsource = img });
                activityIndicator.IsRunning = false;


            }

public ObservableCollection TextContainer { get; set; } = new ObservableCollection();

public static async Task UploadFileAsync(ContainerType containerType, Stream stream)
{
var container = GetContainer(containerType);
await container.CreateIfNotExistsAsync();

        var name = Guid.NewGuid().ToString();
        var fileBlob = container.GetBlockBlobReference(name);
        await fileBlob.UploadFromStreamAsync(stream);

        return name;
    }

Picker WidthRequest .

$
0
0

Hello ! I try to put WidthRequest for Picker and in the windows it's does not work . But if I not use this parameter is does not work good in android . In both case is problem too small Picker and is present only begin of the item . How can I solve this problem ?

Google translate API in Xamarin Forms

$
0
0

I want to use the Phrasebook (the bookmarked words in Google translate) of the logged-in Google user in a Xamarin Forms application, is it available?

Viewing all 58056 articles
Browse latest View live


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