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

Taking advantage of shell routing with hierarchical data

$
0
0

Hello,

While going on with the refactoring of my app to take advantage of Shell and Routing, I'd like to discuss what the best option for following use case.

I have hierarchical data with a list page, a detail page showing detail of the element and list of subelements. Let's take an example based on the sample for the Shell Flyout:

  • Page "Animals" (route = animals)
    • Monkeys (route = species, parameter = type=monkeys)
    • Elephants (route = species, parameter = type=elephants)

On the "detail page" of an animal (thus route=animals/species), we show a list of corresponding animals where again we may show details, thus we could have a detail page for a gorilla and the same XAML page but with different parameter to show a Orang-Outan or an Asian Elephant.

When NOT using routes, you just push new detail page onto the Navigation stack and that's fine, when you go back you are in the proper context of either monkeys or elephants.

Now, somewhere else in my app I have a way to directly navigate to a detail page (this could be for instance the result of a search page going over both monkeys and elephants) and I'd like from that context go to the detail page of a gorilla. I will need a call of the form:

Shell.Current.GoToAsync("//animals/species/profile?animal=gorilla");

and it will work, but when going back to the species page, I won't be in the context of monkeys.

I could possibly navigate to "//animals/species/profile?animal=gorilla&type=monkeys" (did not test) but this is not really pretty and possibly this won't work as I suspect the type argument would be passed to the profile page and not available anymore to the species page.

Nevertheless, what would be the best practice for such use case?


Tried ALL Xamarin BLE Demo Apps - None of them are working

$
0
0

It's the first time I register for a forum, because I couldn't find a solution somewhere in the internet.

I have an arduino and connected a bluetooth module. The module is a HM10 (i also have the HC08). This bluetooth module is for a bluetooth low energy (ble) connection.

Now I want to build an app for android and iOS which is able to communicate with the arduino over ble.

If I download the app "BLE Scanner" from the Play Store (guess it's written in java) I can connect to the arduino. So I have proof that my arduino setup works.

This is my concept:
1. Finding a working BLE Demo App
2. Looking in the source code and implement it in my own app.

Im searching in the internet for more than 3 months and couldn't find one single working BLE Demo app!!! Why? How in the world is this possible?

There are also many different Plugins for BLE, but none of them works. Can't someone delete this? It's just time wasting!

I tried ALL available Demo Apps in the internet for more than 3 months. Here are some links:
h-ttps://github.com/ricardoromo/BLEArduino/tree/master/BLEArduino
h-ttps://github.com/xabre/xamarin-bluetooth-le
h-ttps://github.com/aritchie/bluetoothle
h-ttps://github.com/xamarin/Monkey.BluetoothLE/tree/master/Sample%20Apps/BLE%20Explorer/BLEExplorer
h-ttps://github.com/nexussays/ble.net
very disappointed --> h-ttps://medium.com/@didourebai/integrate-and-use-the-ble-plugin-for-xamarin-edd6d8a1096d
h-ttps://acaliaro.wordpress.com/2017/02/07/connect-a-barcode-reader-to-a-xamarin-forms-app-via-bluetooth/comment-page-1/
h-ttps://greenfinch.ie/2016-07-06-bluetooth-le/

There were more links...so I'm pretty sure I don't need someone who's answer is just copying another link to a BLE demo app, because I tried them ALL!

Is there anybody who recently build a working Xamarin Forms BLE App? Or is this not possible anymore in Xamarin? I would be so so so thankful if there is someone who can send me his own source code to a real working BLE App.

Thanks in advance!

I'm new here so I couldn't post links, thats why I wrote h-ttps.

Button click to navigate to existing page in SQLite database

$
0
0

I have an SQLite database in my app and want to navigate to a specific page by clicking the button (retrieving it from the database). I have GetPageAsync method in my database:

public Task<List<ArtistPageModel>> GetPageAsync(string keyword)
        {
            return database.Table<ArtistPageModel>().Where(i => i.Name == keyword).ToListAsync();
        }

And ButtonClicked on page where it should be done:

private async void Button_Clicked(object sender, EventArgs e)
    {
        var keyword = "Text";
        var page = await App.Database.GetPageAsync(keyword);
        await Navigation.PushAsync(page);
    }

I know this is wrong but I don't have any other solution because I'm just starting with it. Any help would be appreciated.

How to Change Shell Tabar Font to small letter.

Is it possible to use EventListener from Android through Interface in main App?

$
0
0

I tried to make it work modifying the official example (from docs.microsoft.com: the path: /en-us/xamarin/xamarin-forms/app-fundamentals/dependency-service/introduction), but seems like interface demands a value to return and the following doesn't work:
public interface IRetrieveDataService
{
RetrieveData();
}

The EventListner I'd like to use through Interface is described in this video from youtube.com: the path: /watch?v=OC-dy3YFLoo
Source code is in the video's description.

Sorry for paths, I can't post links yet :(

Opening a datepicker view with the click event button in a toolbar item

$
0
0

Hello

I have a datepicker inside a stacklayout, what i want to do is open the datepicker when the user clicks a button (any button)

DatePicker startDate = new DatePicker
            {
                Format = "D",
                BackgroundColor = Color.Green,
                WidthRequest = width,
                MinimumDate = today,
            };

I have achieve this in android with the dependency service and using a "DatePickerDialog dialog"

but in windows phone I can't figure this out, I am currently doing something like this (in the windows phone class):

Microsoft.Phone.Controls.DatePicker test = new Microsoft.Phone.Controls.DatePicker();
Microsoft.Phone.Controls.DatePickerPage testie = new DatePickerPage();

        public PickerRenderer() 
        {
            test.Width = 0;
            testie.Width = 0;
            test.Height = 0;
            testie.Height = 0;
            this.Content = testie;
        }
        public void buttonClicked(Label aLbl)
        {
            test.Focus();
            testie.Focus();
        }

I have also tried gaining the focus of the element in Xamarin.forms like this:

if (Device.OS == TargetPlatform.WinPhone)
            {

                mainLayout.Children.Add(startDate);
                toolbarItem = new ToolbarItem("Add", "plus.png", () =>
                {

                    startDate.Focus();
                }, 0, 0);
                ToolbarItems.Add(toolbarItem); 
            }

But without any success, also there isn't a datepicker.open() or datepicker.show() function.

Any other ideas?

How to write/read Data Table in step definition from Scenario Outline in (Xamarin UI test, Specflow)

$
0
0

Hi, I want to know how to write/read/call Data Table values in step definition from Scenario Outline (feature file) in (Xamarin UI test, Specflow)

Feature: DataTable
@mytag
Scenario Outline: eating
Given there are cucumbers
When I eat cucumbers
Then I should have cucumbers
Examples:
| start | eat | left |
| 12 | 5 | 7 |
| 20 | 5 | 15 |
| 10 | 5 | 5 |
| 15 | 10 | 5 |

Stepdefinition.cs

   [Given(@"there are (.*) cucumbers")]
    public void GivenThereAreCucumbers(int p0)
    {
        ScenarioContext.Current.Pending();
    }

    [When(@"I eat (.*) cucumbers")]
    public void WhenIEatCucumbers(int p0)
    {
        ScenarioContext.Current.Pending();
    }

    [Then(@"I should have (.*) cucumbers")]
    public void ThenIShouldHaveCucumbers(int p0)
    {
        ScenarioContext.Current.Pending();
    }

please let me know anyone having solution/examples for this.

how do i make a fly out menu on the right side of the screen

$
0
0

i wanna make a flyout menu on the right side of the screen rather then the left and wondering how.


Taking advantage of shell routing with hierarchical data

$
0
0

Hello,

While going on with the refactoring of my app to take advantage of Shell and Routing, I'd like to discuss what the best option for following use case.

I have hierarchical data with a list page, a detail page showing detail of the element and list of subelements. Let's take an example based on the sample for the Shell Flyout:

  • Page "Animals" (route = animals)
    • Monkeys (route = species, parameter = type=monkeys)
    • Elephants (route = species, parameter = type=elephants)

On the "detail page" of an animal (thus route=animals/species), we show a list of corresponding animals where again we may show details, thus we could have a detail page for a gorilla and the same XAML page but with different parameter to show a Orang-Outan or an Asian Elephant.

When NOT using routes, you just push new detail page onto the Navigation stack and that's fine, when you go back you are in the proper context of either monkeys or elephants.

Now, somewhere else in my app I have a way to directly navigate to a detail page (this could be for instance the result of a search page going over both monkeys and elephants) and I'd like from that context go to the detail page of a gorilla. I will need a call of the form:

Shell.Current.GoToAsync("//animals/species/profile?animal=gorilla");

and it will work, but when going back to the species page, I won't be in the context of monkeys.

I could possibly navigate to "//animals/species/profile?animal=gorilla&type=monkeys" (did not test) but this is not really pretty and possibly this won't work as I suspect the type argument would be passed to the profile page and not available anymore to the species page.

Nevertheless, what would be the best practice for such use case?

App Icons iOS 13

$
0
0

Hello,

can anybody tell me how to provide App Icons for iOS 13?
I can'T upload my App because Xcode complaints that the App Icons are missing?

How to change text of a button in the main App from App.Android realtime?

$
0
0

Hi!

I'm receiving realtime data from platform-specific code (Firebase Realtime Database) with EventListener, but my UI is in the main App. I can't figure out how to change button text in the main App from the App.Android code realtime.

Tried Interfaces, Binding and MessagingCenter with no success.

I just want to show how many unread messages a person currently has. Like: $"You have {unreadMessagesSize} unread messages"

With Xamarin Forms Shell, is it possible to create a Bottom Tabbar item that just runs a Command?

$
0
0

Something like:
< Tab Title="Export" Command="{Binding ExportCommand}"> ...
< /Tab>

How to change/modify Android platform style at runtime?

$
0
0

Hello,

I would like to change android platform style from forms project according to selected app theme. If possible, I don’t want just to choose any pre-defined android platform style (in Resources/values/styles.xml) but I would like to dynamically change some keys or dynamically create new platform style based on current style, with modified some keys.

How can I achieve that?

Any advice very appreciated! :smile:

I want to Suffle two Tab inside Tabbar Shell in code behide runtime.

$
0
0

Here My Xaml Code I want to suffle below two tab at runtime.

        <ShellContent x:Name="se1" Style="{StaticResource DomesticShell}" 
                      Title="ପ୍ରଚ୍ଛଦ" ContentTemplate="{DataTemplate OdiaContent:Happenings}"  />

    </Tab>

  <Tab x:Name="EngTab" Route="English"     Icon="eng">


        <ShellContent Style="{StaticResource DomesticShell}"
                      Title="Home" ContentTemplate="{DataTemplate EngContent:TestSkeleton}"  />


</TabBar>

Webview Navigation events not firing on iOS

$
0
0

Hi i have using following code working fine android but not get response from iOS in xamarin forms

         public async void WebViewnavigated(WebNavigatedEventArgs args, NavigationEventArgs e, string url)
            {
                try
                {
                    var obj = Newtonsoft.Json.JsonConvert.SerializeObject(web_view_login.Source);
                    var uri = Newtonsoft.Json.JsonConvert.DeserializeObject<JObject>(obj)["Url"];


                    var access_token = uri.ToString();

                    if (access_token.Contains("access_token"))
                    {
                        var accesstoken_ = uri.ToString().Split(new char[] { '?', '&', '{', '}', '=' })[2];
                        var token_type = uri.ToString().Split(new char[] { '?', '&', '{', '}', '=' })[4];
                        await Navigation.PushAsync(new Home());
                        //await Navigation.PopAsync();
                    }
                }
                catch (Exception ex)
                {

                }

            }

OnAppearing Event - Called before page is drawn on Android

$
0
0

I have a forms app and I am getting different behavior when I load my tabbed pages into the navigation stack. For some reason the OnAppearing method of one of my content pages gets fired immediately in Android only. Ios it functions as expected and only fires once the page "Appears". My question is how do I ensure my "OnAppearing" method actually fires when the page is drawn or Appears on the screen. I have some logic that refreshes the page and the fact it does not fire when it is initially navigated to is causing problems in Android. Here is my main page xaml when I setup my pages

      public MainPage()
            {
                InitializeComponent();

                Page HomePage, TestPage, UserPage = null;


                HomePage = new NavigationPage(new HomePage())
                {
                    Title = "Home" 
                };
               TestPage = new NavigationPage(new TestPage())
                {
                    Title = "Test"
                };
                UserPage = new NavigationPage(new UserPage())
                {
                    Title = "Users"
                };


            Children.Add(HomePage);
                Children.Add(TestPage);
                Children.Add(UsersPage);



    }

App.xaml.cs

    public App()
            {
                InitializeComponent();

                MainPage = new MainPage();

            }

    }

How to get notified when a user turn on / turn off location services in Xamarin forms?

$
0
0

I have an application consists of map, I need to show pins when location is on and when location is turned off I need to hide the pins. I need to implement this in both Android and iOS.

How to disable a specific row from clicking on a Sf Data Grid in Xamarin?

$
0
0

I have created a data grid, I want to disable the specific row and make it read only when the second column contain value less than 18.. How can I achieve that? I have done some research online and I have learnt to create a method as following:

private void DataGrid_DisableSpecifcRow(object sender, CurrentCellActivatingEventArgs e)
{

}

However, I just don't know how to disable the specific row. Using the e, there is no option like e.RowIndex.Disable(). Thanks in advance.

Open Source Zebra RFID SDK for Xamarin Forms

$
0
0

Hello,

Zebra Technologies have SDKs for their RFID Scanners on platforms including native iOS, native Android and Xamarin.Android however not for Xamarin.iOS or Xamarin.Forms.

We are currently building a Xamarin.Forms app which critically requires the use of the RFID Scanner (RFD8500 model to be precise) on iOS. Our understanding is that this can be achieved by creating an iOS Binding Library for Zebra's existing Objective-C iOS SDK. I have personally attempted to bind this library through two methods, one being the classic iOS Binding method and two, creating a local C# Nuget Package for consumption. Due to lack of Objective-C experience, both attempts were unsuccessful.

What we would like to know is:

  • Is what we are trying to do even possible? (i.e would a binding library be enough to get the RFID scanners to work with a .forms app)
  • If so, what is the scale of effort?
  • As we lack the technical skills for it, would anybody be up for getting involved in this Open Source? (doing the actual work)

I think this would be a great project to do as over the last few months, I have found that a LOT of developers/companies have suffered from this same issue.

Thank you
Ridhwan

xamarin forms ios release build hangs

$
0
0

I'm running VS 2019 from my windows machine and connecting to my Mac through VS. I can successfully connect to the Mac without issue. The problem arises when I perform a release build, the build hangs on "compiling to native". When I cancel the build the following output is displayed on the output console:

5>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(842,3): warning : The client build16408Alpha has been disconnected while waiting a post response to topic xvs/Build/16.3.0.278/execute-task/UI.iOS/1951504002fMTouch 5>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(842,3): warning : An error occurred on the underlying client while executing an operation. Details: The client has been disconnected while trying to perform the unsubscribe to topics: xma/last-will 5>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(842,3): warning : The client build16408Alpha has been disconnected while waiting a post response to topic xvs/Build/16.3.0.278/execute-task/UI.iOS/1951504002fMTouch 5>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(842,3): warning : at Xamarin.Messaging.Client.MessagingClient.d__232.MoveNext() in E:\A_work\445\s\External\messaging\src\Xamarin.Messaging.Client\MessagingClient.cs:line 175
5>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(842,3): warning : System.Net.Mqtt.MqttClientException: The client has been disconnected while trying to perform the unsubscribe to topics: xma/last-will
5>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(842,3): warning : at System.Net.Mqtt.Sdk.MqttClientImpl.d__33.MoveNext() in E:\A_work\2653\s\src\Client\Sdk\MqttClientImpl.cs:line 302
5>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(842,3): warning : --- End of stack trace from previous location where exception was thrown ---
5>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(842,3): warning : at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
5>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(842,3): warning : at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
5>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(842,3): warning : at Xamarin.Messaging.Client.TopicObservable1.d.MoveNext() in E:\A_work\445\s\External\messaging\src\Xamarin.Messaging.Client\TopicObservable.cs:line 32 5>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(842,3): error : The client build16408Alpha has been disconnected while waiting a post response to topic xvs/Build/16.3.0.278/execute-task/UI.iOS/1951504002fMTouch

It seems like the connection to the Mac drops off midway when performing a release build. All my software is up to date. I can also run the iOS simulators on the Mac in debug mode. Any help would be much appreciated.. Thanks in advance !

Viewing all 81910 articles
Browse latest View live


Latest Images

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