Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all 204402 articles
Browse latest View live

How to read the value from the username text box of my login page loaded in the xamarin android web

$
0
0
I'm trying to get the value in the user name text box from my login page after the user entered it in a web page using webview in Xamarin android.

I tried using "document.getelementbyid('useranme').values"

but it is always returning null values. Can any one please help ?

Error after upgrading to Xcode 11 ?

$
0
0

Hi,

I am getting below error when i try to run the project from visual studio 2019 for windows.

"Distill failed for unknown reasons"

Please find the below versions which i am using for dev.

Windows: (VISUAL STUDIO 2019)

Visual Studio : 16.3.3

Xamarin. Android SDK 10.0.3.0

Xamarin.iOS 13.2.0.47

MAC:

Xamarin. Android SDK 10.0.3.0

Xamarin.iOS 13.2.0.47

XCODE 11

OS Version : Catalina beta 10.15

Please share your suggestion to fix this issue.

Thanks

SelectedIndex for CardView

$
0
0

Hi everyone !

I use CardView Plugin in my application.

When the user clicks on any of the cards, I want to go to that card's detail page. Since there is a dynamically variable number of cards, I want to get the index of the card that the user clicks on. Because I have to show the details of the selected card on the detail page.

I tried to do that, but I couldn't find the solution. However, there is a variable called position in the plugin documentation. I think I should solve my problem with this.

cs.Side

    void selectedCollection(object sender, EventArgs args)
    {
        var item = model[1];
                Navigation.PushAsync(new DlAnayasaPage(item.CampaignName,item.CampaignPicture));
    }

For example, when I clicked on the image using a GestureRecognizer, I said go to the detail page. Everything is very beautiful. But I couldn't use the dynamic position instead of the number 1 here.(model[1])

How can i solved ?

Direction for renderer

$
0
0

[Posted in University but board seemed a bit slow]

I am looking for advice on producing a window to render output into. I want to build game frames but I am unsure of the limitations Xamarin would have for this kind of function.

Another option is building an application in Unity if I can then somehow place my game inside a Xamarin application.

Is there any way I can create executable or library compatible to Android using Xamarin

$
0
0

I have code in C# core to provision, register IoT devices to IoT hub Azure using Azure C# sdk

I would like to use that to work in Android Device.

Is there any way I can build executable and libraries compatible to Android using Xamarin

Send link in push notification through Firebase Cloud Messaging

$
0
0

Hello
I have a Xamarin android application integrated with Firebase cloud messaging. How can I send a link in the push notifications. So that, whenever a user clicks, it opens the link directly in-app browser.

How to create an Unsigned XCARCHIVE file with Visual Studio ?

$
0
0

How to create an Unsigned XCARCHIVE file with Visual Studio 2019 ?

Xamarin forms: Display the title, subtitle and numbered points in UI from HTML data

$
0
0

I converted HTML data into string using HtmlAgilityPack. But I need to format the text again like the following.

Sample HTML data added on here.

My text has a title, subtitle, and numbered points. So how can I change the data like the above screenshot?


Issue with Microsoft.Http.Net library - Operation is not valid due to the current state of the objec

$
0
0

Hello friends,

I'm dealing with an issue on iOS, the app works perfectly on Simulator, but it does not work on physical device.

This is the inner exception of the error:

    System.InvalidOperationException: Operation is not valid due to the current state of the object
      at System.Lightup.Call[HttpWebRequest,Int64] (System.Delegate& storage, System.Net.HttpWebRequest instance, System.String methodName, Int64 parameter) [0x00000] in <filename unknown>:0 
      at System.Lightup.Set[HttpWebRequest,Int64] (System.Delegate& storage, System.Net.HttpWebRequest instance, System.String propertyName, Int64 value) [0x00000] in <filename unknown>:0 
      at System.Net.HttpWebRequestLightup.SetContentLength (System.Net.HttpWebRequest instance, Int64 value) [0x00000] in <filename unknown>:0 
      at System.Net.Http.HttpWebRequest.set_ContentLength (Int64 value) [0x00000] in <filename unknown>:0 
      at System.Net.Http.HttpClientHandler.StartRequest (System.Object obj) [0x00000] in <filename unknown>:0 

I tried the workaround of the app.config file and also gave it a try to set the Microsoft.Net.Http to false (local copy) and none of that worked.

I checked these 2 pages of the bugs:
https://bugzilla.xamarin.com/show_bug.cgi?id=20589
and https://bugzilla.xamarin.com/show_bug.cgi?id=17936

None of the workaround worked for me. Any ideas or workaround are always welcome.

Thanks in advance

Correct signature not found error

$
0
0

Hi, I'm trying to get some event triggers working to move between screens. I'm currently getting an error of
"Error Position 12:33. EventHandler "OnTap" with a correct signature not found in type "UniversalMemo.Views.Page.FolderPage"

I've looked around on the net and haven't found anything that helped. I removed the x:class reference to FolderPage but the app then hard crashes on the emulator.

I've cleaned the build many times.
I have a factory reset and rebuild the android emulator multiple times. (I've also done both the above step and this one at the same time)
I think this code may have been working before I did a Visual studio and Xamarin update or 2 ago. I'm not sure what to do to fix this right now other than starting a new project and importing this one into it.

Below is the code

XAML

<?xml version="1.0" encoding="utf-8" ?>

<ContentPage.ToolbarItems>
    <ToolbarItem Text="Add" Clicked="OnTap" />
</ContentPage.ToolbarItems>

...etc...

C#

    protected async void OnTap(object sender, EventArgs e)
    {
       await Navigation.PushModalAsync(new NavigationPage(new NewFolderPage()));
    }

Xamarin.Mac app crash

$
0
0

Using latest XCode 11.1 (11A1027) together with Visual Studio.Net for Mac (8.3.4) and Xamarin.Mac (6.4.0.2) after I create an installer and then run my application the application crash immediately.

am using the exact same unmodified codebase from a git-tag that i used before when i went live in the AppStore with the previous app release so my guest is something is wrong with the toolset and not my codebase.

I found that this happens when i sign the application for distribution from within Xamarin IDE when a package gets created.
If I compile a .app without signing it then it works fine.

CancellationToken.ThrowOperationCanceledException

$
0
0

I am getting the following error on my Xamarin.Forms project:

  {System.OperationCanceledException: The operation was canceled.
  at System.Threading.CancellationToken.ThrowOperationCanceledException () [0x00010] in <46c2fa109b574c7ea6739f9fe2350976>:0 
  at System.Threading.CancellationToken.ThrowIfCancellationRequested () [0x00008] in <46c2fa109b574c7ea6739f9fe2350976>:0 
  at Xamarin.Android.Net.AndroidClientHandler+<>c__DisplayClass44_0.<ConnectAsync>b__0 () [0x0004f] in 
  /Users/vsts/agent/2.155.1/work/1/s/src/Mono.Android/Xamarin.Android.Net/AndroidClientHandler.cs:343 
  at System.Threading.Tasks.Task.InnerInvoke () [0x0000f] in <46c2fa109b574c7ea6739f9fe2350976>:0 
  at System.Threading.Tasks.Task.Execute () [0x00000] in <46c2fa109b574c7ea6739f9fe2350976>:0 

--- End of stack trace from previous location where exception was thrown ---

  at Xamarin.Android.Net.AndroidClientHandler.DoProcessRequest (System.Net.Http.HttpRequestMessage request, Java.Net.URL javaUrl, 
  Java.Net.HttpURLConnection httpConnection, System.Threading.CancellationToken cancellationToken, 
  Xamarin.Android.Net.AndroidClientHandler+RequestRedirectionState redirectState) [0x000e4] in 
 /Users/vsts/agent/2.155.1/work/1/s/src/Mono.Android/Xamarin.Android.Net/AndroidClientHandler.cs:393 
  at Xamarin.Android.Net.AndroidClientHandler.SendAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken 
  cancellationToken) [0x00285] in /Users/vsts/agent/2.155.1/work/1/s/src/Mono.Android/Xamarin.Android.Net/AndroidClientHandler.cs:286 
  at System.Net.Http.HttpClient.FinishSendAsyncBuffered (System.Threading.Tasks.Task`1[TResult] sendTask, System.Net.Http.HttpRequestMessage 
  request, System.Threading.CancellationTokenSource cts, System.Boolean disposeCts) [0x0017e] in <814c177e4f174da89876fafdde15d02e>:0 
  at BUCOLogin.Constants.RestService.GetBranchesAsync (System.String uri) [0x00046] in C:\Visual Studio Training\BUCO FR 
  Login\FacialRecognitionLogin\Constants\RestService.cs:18 }

After some investigation it seems that a token is being cancelled, but I'm not sure where this token is located or even why its being cancelled. I am using an open API request with no APIKey needed :

Constants.cs:

 using System;
 using System.Collections.Generic;
 using System.Text;

 namespace BUCOLogin.Constants
 {
  public static class Constants
  {
    public const string OpenBabbageEndpoint = "HTTP-LINK";
    //public const string OpenBabbageAPIKey = "f6a04a6c3fbc534c295f6a5e8548e0f6";
  }
 }

When stepping through code, it stalls/waits for a while at the following code before giving me the exception:

 HttpResponseMessage response = await _client.Value.GetAsync(uri);

 This code is located in RestService.cs:

 using System;
 using System.Diagnostics;
 using System.Net.Http;
 using System.Threading.Tasks;
 using Newtonsoft.Json;

namespace BUCOLogin.Constants
{
   public class RestService
   {
    static Lazy<HttpClient> _client = new Lazy<HttpClient>(() => new HttpClient());

    public async Task<GetBranches> GetBranchesAsync(string uri)
    {
        GetBranches branchesData = null;
        try
        {
            HttpResponseMessage response = await _client.Value.GetAsync(uri);
            if (response.IsSuccessStatusCode)
            {
                string content = await response.Content.ReadAsStringAsync();
                branchesData = JsonConvert.DeserializeObject<GetBranches>(content);
            }
        }
        catch (Exception ex)
        {
            Debug.WriteLine("\tERROR {0}", ex.Message);
        }

        return branchesData;
     }
   }
  }

GetBranches.cs:

  using System;
  using System.Collections.Generic;
  using System.Text;
  using Newtonsoft.Json;

  namespace BUCOLogin.Constants
 {
   public class GetBranches
  {

    [JsonProperty("name")]
    public string Name { get; set; }

    [JsonProperty("number")]
    public string Number { get; set; }

    [JsonProperty("postcode")]
    public string Postcode { get; set; }

    [JsonProperty("manager")]
    public string Manager { get; set; }

    [JsonProperty("phone")]
    public string Phone { get; set; }

    [JsonProperty("address")]
    public string Address { get; set; }

    [JsonProperty("open")]
    public string Open { get; set; }

    [JsonProperty("close")]
    public string Close { get; set; }

    [JsonProperty("opensat")]
    public string Opensat { get; set; }

    [JsonProperty("closesat")]
    public string Closesat { get; set; }

    }
  }

The uri Request does bring back multiple results on Postman so I am not sure why I am getting this exception and how to move forward.

Thanks in advance.

CancellationToken.ThrowOperationCanceledException

$
0
0

I am getting the following error on my Xamarin.Forms project:

{System.OperationCanceledException: The operation was canceled.
at System.Threading.CancellationToken.ThrowOperationCanceledException () [0x00010] in <46c2fa109b574c7ea6739f9fe2350976>:0
at System.Threading.CancellationToken.ThrowIfCancellationRequested () [0x00008] in <46c2fa109b574c7ea6739f9fe2350976>:0
at Xamarin.Android.Net.AndroidClientHandler+<>c__DisplayClass44_0.b__0 () [0x0004f] in /Users/vsts/agent/2.155.1/work/1/s/src/Mono.Android/Xamarin.Android.Net/AndroidClientHandler.cs:343
at System.Threading.Tasks.Task.InnerInvoke () [0x0000f] in <46c2fa109b574c7ea6739f9fe2350976>:0
at System.Threading.Tasks.Task.Execute () [0x00000] in <46c2fa109b574c7ea6739f9fe2350976>:0
--- End of stack trace from previous location where exception was thrown ---

at Xamarin.Android.Net.AndroidClientHandler.DoProcessRequest (System.Net.Http.HttpRequestMessage request, Java.Net.URL javaUrl, Java.Net.HttpURLConnection httpConnection, System.Threading.CancellationToken cancellationToken, Xamarin.Android.Net.AndroidClientHandler+RequestRedirectionState redirectState) [0x000e4] in /Users/vsts/agent/2.155.1/work/1/s/src/Mono.Android/Xamarin.Android.Net/AndroidClientHandler.cs:393
at Xamarin.Android.Net.AndroidClientHandler.SendAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) [0x00285] in /Users/vsts/agent/2.155.1/work/1/s/src/Mono.Android/Xamarin.Android.Net/AndroidClientHandler.cs:286
at System.Net.Http.HttpClient.FinishSendAsyncBuffered (System.Threading.Tasks.Task`1[TResult] sendTask, System.Net.Http.HttpRequestMessage request, System.Threading.CancellationTokenSource cts, System.Boolean disposeCts) [0x0017e] in <814c177e4f174da89876fafdde15d02e>:0
at BUCOLogin.Constants.RestService.GetBranchesAsync (System.String uri) [0x00046] in C:\Visual Studio Training\BUCO FR Login\FacialRecognitionLogin\Constants\RestService.cs:18 }

After some investigation it seems that a token is being cancelled, but I'm not sure where this token is located or even why its being cancelled. I am using an open API request with no APIKey needed :

Constants.cs:

using System;
using System.Collections.Generic;
using System.Text;

namespace BUCOLogin.Constants
{
public static class Constants
{
public const string OpenBabbageEndpoint = "HTTP-LINK";
//public const string OpenBabbageAPIKey = "f6a04a6c3fbc534c295f6a5e8548e0f6";
}
}

When stepping through code, it stalls/waits for a while at the following code before giving me the exception:

HttpResponseMessage response = await _client.Value.GetAsync(uri);

This code is located in RestService.cs:

using System;
using System.Diagnostics;
using System.Net.Http;
using System.Threading.Tasks;
using Newtonsoft.Json;

namespace BUCOLogin.Constants
{
public class RestService
{
static Lazy _client = new Lazy(() => new HttpClient());

    public async Task<GetBranches> GetBranchesAsync(string uri)
    {
        GetBranches branchesData = null;
        try
        {
            HttpResponseMessage response = await _client.Value.GetAsync(uri);
            if (response.IsSuccessStatusCode)
            {
                string content = await response.Content.ReadAsStringAsync();
                branchesData = JsonConvert.DeserializeObject<GetBranches>(content);
            }
        }
        catch (Exception ex)
        {
            Debug.WriteLine("\tERROR {0}", ex.Message);
        }

        return branchesData;
    }
}

}

GetBranches.cs:

using System;
using System.Collections.Generic;
using System.Text;

using Newtonsoft.Json;

namespace BUCOLogin.Constants
{
public class GetBranches
{

    [JsonProperty("name")]
    public string Name { get; set; }

    [JsonProperty("number")]
    public string Number { get; set; }

    [JsonProperty("postcode")]
    public string Postcode { get; set; }

    [JsonProperty("manager")]
    public string Manager { get; set; }

    [JsonProperty("phone")]
    public string Phone { get; set; }

    [JsonProperty("address")]
    public string Address { get; set; }

    [JsonProperty("open")]
    public string Open { get; set; }

    [JsonProperty("close")]
    public string Close { get; set; }

    [JsonProperty("opensat")]
    public string Opensat { get; set; }

    [JsonProperty("closesat")]
    public string Closesat { get; set; }

}

}

The uri Request does bring back multiple results on Postman so I am not sure why I am getting this exception and how to move forward.

Thanks in advance.

RichText Box in Xamarin forms?

$
0
0

Can anyone please let me know how to add the RichText box for Xamarin forms app.
Please help me. Thanks in advance.

How do i share a png with RequestAsync ShareFileRequest?

$
0
0

Hello Xamarin Community Forum,

I can't find out how to share an image(png) with Xamarin.Essentials; how do you do it?


ControlTemplate Bind to Source={x:Reference}

$
0
0

Hello guys,

is it possible in Xamarin.Forms to bind inside a controlTemplate to the main ContentView via Source {x:Reference}?

I want to do something like below.

    <ContentView x:Name=**"root"**>
        <ContentView.Resources>
            <ResourceDictionary>
                <ControlTemplate x:Key="temp1">
                    <Label Text="{Binding **Source={x:Reference root}, Path=BindingContext.TextToShow}"**/>
                </ControlTemplate>
            </ResourceDictionary>
        </ContentView.Resources>
        <ListView>
            <ListView.ItemTemplate>
                <DataTemplate>
                    <ContentView ControlTemplate="{StaticResource temp1}"/>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>
    </ContentView>

Greets

when click notification App is crash

$
0
0

i use Shell On MainPage
when App is Active And click receved Notification
give error
System.NullReferenceException: Object reference not set to an instance of an object.
at Xamarin.Forms.Platform.Android.ShellSectionRenderer.UnhookEvents () [0x00022] in D:\a\1\s\Xamarin.Forms.Platform.Android\Renderers\ShellSectionRenderer.cs:254
at Xamarin.Forms.Platform.Android.ShellSectionRenderer.OnDestroy () [0x00008] in D:\a\1\s\Xamarin.Forms.Platform.Android\Renderers\ShellSectionRenderer.cs:180
at Android.Support.V4.App.Fragment.n_OnDestroy (System.IntPtr jnienv, System.IntPtr native__this) [0x00008] in :0
at at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.47(intptr,intptr)

how to allow to upload less than 4 photo

$
0
0

Hi xamarin forum

I have created uploading 4 photo to server however if I try to upload like 2 photos the app crashes anyway here is the code for uploading

Upload.cs

        public partial class PostCreationPage : ContentPage
        {
            public List<t_Post> postslist;
            string json;

            public PostCreationPage()
            {
                InitializeComponent();

            }
            private MediaFile _mediaFile;
            private MediaFile _mediaFile2;
            private MediaFile _mediaFile3;
            private MediaFile _mediaFile4;

            List<string> _images = new List<string>();

         private async void Upload_File(object sender, EventArgs e)
            {
                var content = new MultipartFormDataContent();
                var content2 = new MultipartFormDataContent();
                var content3 = new MultipartFormDataContent();
                var content4 = new MultipartFormDataContent();

                string userfirstname = App.FirstName;

                var page = new LoadingPage();




                content.Add(new StreamContent(_mediaFile.GetStream()),
                    "\"file\"",
                    $"\"{_mediaFile.Path}\"");

                content2.Add(new StreamContent(_mediaFile2.GetStream()),
                        "\"file\"",
                        $"\"{_mediaFile2.Path}\"");

                content3.Add(new StreamContent(_mediaFile3.GetStream()),
                        "\"file\"",
                        $"\"{_mediaFile3.Path}\"");

                content4.Add(new StreamContent(_mediaFile4.GetStream()),
                        "\"file\"",
                        $"\"{_mediaFile4.Path}\"");



                await PopupNavigation.Instance.PushAsync(page);

                var httpClient = new HttpClient();
                var uploadServiceBaseAddress = "http://xxx.xx.xx.xxx:8087/api/Files/Uploads";

                var httpResponseMessage = await httpClient.PostAsync(uploadServiceBaseAddress, content);
                var httpResponseMessage2 = await httpClient.PostAsync(uploadServiceBaseAddress, content2);


                var Absolutepath_1 = "http://xxx.xx.xx.xxx:8087/Uploads";
                var Absolutepath_2 = "http://xxx.xx.xx.xxx:8087/Uploads";
                var Absolutepath_3 = "http://xxx.xx.xx.xxx:8087/Uploads";
                var Absolutepath_4 = "http://xxx.xx.xx.xxx:8087/Uploads";

                var pathToLabel = httpResponseMessage.Content.ReadAsStringAsync().ToString();
                var pathToLabel2 = httpResponseMessage2.Content.ReadAsStringAsync().ToString();

                string pathName = Path.GetFileName(_mediaFile.Path);
                string pathName2 = Path.GetFileName(_mediaFile2.Path);
                string pathName3 = Path.GetFileName(_mediaFile3.Path);
                string pathName4 = Path.GetFileName(_mediaFile4.Path);

                string pathNames = Absolutepath_1 + "/" + pathName;
                string pathNames2 = Absolutepath_2 + "/" + pathName2;
                string pathNames3 = Absolutepath_3 + "/" + pathName3;
                string pathNames4 = Absolutepath_4 + "/" + pathName4;

                Pipeline databaseConnect = new Pipeline();

                try
                {

                    SqlCommand sqlInsert = new SqlCommand("INSERT INTO tablename(House_Name, Post_Content, Photo, Photo_2, Photo_3, Photo_4, Location, Floor_Area, Price, Bedroom, Toilet_And_Bath, Storey, Uploader, Date_Uploaded) " +
                    "VALUES(@HouseName, @PostContent, @Photo, @Photo2, @Photo3, @Photo4, @Location, @Price, @Floor, @Bedroom, @TB, @Storey, @Uploader, @DateUploaded)", databaseConnect.connectDB());

                    sqlInsert.Parameters.AddWithValue("@HouseName", HouseName.Text);
                    sqlInsert.Parameters.AddWithValue("@PostContent", postContent.Text);
                    sqlInsert.Parameters.AddWithValue("@Photo", pathNames);
                    sqlInsert.Parameters.AddWithValue("@Photo2", pathNames2);
                    sqlInsert.Parameters.AddWithValue("@Photo3", pathNames3);
                    sqlInsert.Parameters.AddWithValue("@Photo4", pathNames4);
                    sqlInsert.Parameters.AddWithValue("@Uploader", userfirstname);
                    sqlInsert.Parameters.AddWithValue("@DateUploaded", DateTime.Now);
                    sqlInsert.Parameters.AddWithValue("@Location", HouseLocation.Text);
                    sqlInsert.Parameters.AddWithValue("@Price", HousePrice.Text);
                    sqlInsert.Parameters.AddWithValue("@Floor", FloorArea.Text);
                    sqlInsert.Parameters.AddWithValue("@Bedroom", Bedroom.Text);
                    sqlInsert.Parameters.AddWithValue("@TB", BathToilet.Text);
                    sqlInsert.Parameters.AddWithValue("@Storey", Storey.Text);

                    int i = sqlInsert.ExecuteNonQuery();
                    databaseConnect.connectDB().Close();

                    await DisplayAlert("Success", "Uploaded to Database.", "OK");
                    await PopupNavigation.Instance.PopAsync();



                    await Navigation.PopAsync();
                }
                catch (Exception ex)
                {

                }

            }

        }
    }

Thanks in advance

Print PDF file using Xamarin forms

$
0
0

Hello Developers

I am printing a Pdf file via print services.
I implemented some code but not working through a exception java.lang.RuntimeException: Cannot print a malformed PDF file
Please check my code and let me where i am wrong.

    public void Print(byte[] content)
    {
        //Android print code goes here
        Stream inputStream = new MemoryStream(content);
        string fileName = "form.pdf";
        if (inputStream.CanSeek)
        //Reset the position of PDF document stream to be printed
        inputStream.Position = 0;
        //Create a new file in the Personal folder with the given name
        string createdFilePath = System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), fileName);
        //Save the stream to the created file
        using (var dest = System.IO.File.OpenWrite(createdFilePath))
        inputStream.CopyTo(dest);
        string filePath = createdFilePath;
        PrintManager printManager = (PrintManager)Forms.Context.GetSystemService(Context.PrintService);
        PrintDocumentAdapter pda = new CustomPrintDocumentAdapter(filePath);
        //Print with null PrintAttributes
        printManager.Print(fileName, pda, null);
    }

This is my PrintDocumentAdapter

    internal class CustomPrintDocumentAdapter : PrintDocumentAdapter
    {
        private string filePath;
        public CustomPrintDocumentAdapter(string filePath)
        {
            this.filePath = filePath;
        }
        public override void OnLayout(PrintAttributes oldAttributes, PrintAttributes newAttributes, CancellationSignal cancellationSignal, LayoutResultCallback callback, Bundle extras)
        {
            if (cancellationSignal.IsCanceled)
            {
                callback.OnLayoutCancelled();
                return;
            }
            callback.OnLayoutFinished(new PrintDocumentInfo.Builder(filePath)
            .SetContentType(PrintContentType.Document)
            .Build(), true);
        }

        public override void OnWrite(PageRange[] pages, ParcelFileDescriptor destination, CancellationSignal cancellationSignal, WriteResultCallback callback)
        {
            try
            {
                using (InputStream input = new FileInputStream(filePath))
                {
                    using (OutputStream output = new FileOutputStream(destination.FileDescriptor))
                    {
                        var buf = new byte[1024];
                        int bytesRead;
                        while ((bytesRead = input.Read(buf)) > 0)
                        {
                            output.Write(buf, 0, bytesRead);
                        }
                    }
                }
                callback.OnWriteFinished(new[] { PageRange.AllPages });
            }
            catch (FileNotFoundException fileNotFoundException)
            {
                System.Diagnostics.Debug.WriteLine(fileNotFoundException);
            }
            catch (Exception exception)
            {
                System.Diagnostics.Debug.WriteLine(exception);
            }
        }
    }

i am calling Print method in this way

    private void GoToPrintPage_Clicked(object sender, EventArgs e)
    {
        using (var webClient = new WebClient())
        {
            var url = "https://vector.me/files/images/1/7/17513/tottenham_hotspur_fc.png";
            var imageBytes = webClient.DownloadData(new Uri(url));
            DependencyService.Get<Interface.IWifiPrinterConnectivity>().Print(imageBytes);
        }
    }

Why I am getting Cannot remove root page when it is also the currently displayed page?

$
0
0

Hi,

From my MainPage, I am opening:

App.Current.MainPage.Navigation.PushModalAsync(new Xamarin.Forms.NavigationPage(new NewAd()));

and from NewAdd I am opening:

await Navigation.PushModalAsync(new NewAdPhotos(Convert.ToString(data[0].ad_id), selected_sub_category_name));

but I want to remove the NewAd before or after opening NewAdPhotos

I tried this:

await Navigation.PushModalAsync(new NewAdPhotos(Convert.ToString(data[0].ad_id), selected_sub_category_name));

Navigation.RemovePage(this);

but I am getting:

Cannot remove root page when it is also the currently displayed page

How can i solve this please?

Thanks,
Jassim

Viewing all 204402 articles
Browse latest View live


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