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

Two-way binding with a collection

$
0
0

Hi.

I made a multi-selection list component for my project and am struggling to understand how exactly two-way bindings should be implemented for collections. The reason I am doing this is because Xamarin.Forms's collection view has so many issues with the exact same thing - two-way binding of selections.

I am assuming you should make a copy of the list in order not to edit the original list, but my changes are not reflected back to the original list when two-way binding is enabled.

I have tried the following:

  • In the property's coerce value, wrap the incoming IList in an observable collection. When it is edited, changes are not reflected back to the original list when two-way binding is used.
  • In the property's coerce value, create an internal list and copy it back to the property when editing. Changes are not reflected back to the original list when two-way binding is used. I also tried assigning the entire list back.
  • Do nothing special and just use and edit the provided collection. Changes are of course reflected back but not via the bindings, but rather from me editing the incoming list. One-way binding doesn't work as the original list always gets edited.

I even added explicit calls to notify if property changed on the list itself after editing it, tested reassigning it etc but no changes are ever propagated back unless I edit the original list.

So how should this be implemented?

Thanks for insights!


BoxViewRenderer throws null exception when adding Syncfusion Kanban control itemtemplate in iOS

$
0
0

Hi,

Can you please anyone resolve this?

While adding boxview inside of our Syncfusion SfKanban custom control itemtemplate, we faced null reference exception for BoxRenderer in Xamarin.Forms iOS platform. Please find the code snippet below

xmlns:syncfusion="clr-namespace:Syncfusion.SfKanban.XForms;assembly=Syncfusion.SfKanban.XForms"

        <kanban:SfKanban.CardTemplate>

            <DataTemplate>
                <ViewCell>
                     <ViewCell.View>
                          <StackLayout >
                                <BoxView Color="Red"
                                                 CornerRadius="4"
                                                 WidthRequest="160"
                                                 HeightRequest="100"
                                                 HorizontalOptions="FillAndExpand"
                                                 VerticalOptions="FillAndExpand"/>

                         </StackLayout>
                      </ViewCell.View>
                  </ViewCell>
            </DataTemplate>

        </kanban:SfKanban.CardTemplate>

. . .

For more details please refer
https://help.syncfusion.com/xamarin/kanban-board/getting-started

Please find the StackTrace below:

System.NullReferenceException: Object reference not set to an instance of an object
at Xamarin.Forms.Platform.iOS.BoxRenderer.LayoutSubviews () [0x0001b] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\BoxRenderer.cs:50
at 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 /Library/Frameworks/Xamarin.iOS.framework/Versions/13.16.0.11/src/Xamarin.iOS/UIKit/UIApplication.cs:86
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0000e] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.16.0.11/src/Xamarin.iOS/UIKit/UIApplication.cs:65
at GettingStartedKanban.iOS.Application.Main (System.String[] args) [0x00001] in /Users/syncfusion/Downloads/kanban_yu/kanban/GettingStartedKanban/GettingStartedKanban.iOS/Main.cs:17

Regards,
Yuvaraj

How to make Top Tab Bar to Top Bar ?

After my iPhone8 updated to IOS 13.7, i'm not able to run my Xamarin.iOS application to my iPhone

$
0
0

yesterday i updated my iPhone 8 to latest (iOS 13.7) and Xcode to latest Version 11.7 (11E801a). Now i'm not able to run my application in my iPhone. But i can successfully can build my solution. When i run application i'm getting below given error.

Launched application 'com.sasken.bledexadapter' on 'iPhone' with pid 577
Loaded assembly: /private/var/containers/Bundle/Application/E6448FB5-0AD4-4C67-8805-E0DEB54C5113/BLEDexAdapter.app/System.Drawing.Common.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/E6448FB5-0AD4-4C67-8805-E0DEB54C5113/BLEDexAdapter.app/System.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/E6448FB5-0AD4-4C67-8805-E0DEB54C5113/BLEDexAdapter.app/Xamarin.iOS.dll [External]
Thread started: #2
Loaded assembly: /private/var/containers/Bundle/Application/E6448FB5-0AD4-4C67-8805-E0DEB54C5113/BLEDexAdapter.app/System.Core.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/E6448FB5-0AD4-4C67-8805-E0DEB54C5113/BLEDexAdapter.app/BLESDK.dll
Loaded assembly: /private/var/containers/Bundle/Application/E6448FB5-0AD4-4C67-8805-E0DEB54C5113/BLEDexAdapter.app/BLEDexAdapter.exe

=================================================================

Native Crash Reporting

Got a abrt while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries

used by your application.

=================================================================

Native stacktrace:

0x1047a9220 - /private/var/containers/Bundle/Application/E6448FB5-0AD4-4C67-8805-E0DEB54C5113/BLEDexAdapter.app/BLEDexAdapter : 
0x10479febc - /private/var/containers/Bundle/Application/E6448FB5-0AD4-4C67-8805-E0DEB54C5113/BLEDexAdapter.app/BLEDexAdapter : 
0x1047a876c - /private/var/containers/Bundle/Application/E6448FB5-0AD4-4C67-8805-E0DEB54C5113/BLEDexAdapter.app/BLEDexAdapter : 
0x18e036894 - /usr/lib/system/libsystem_platform.dylib : <redacted>
0x18e125e58 - /usr/lib/system/libsystem_kernel.dylib : <redacted>
0x18e125e88 - /usr/lib/system/libsystem_kernel.dylib : <redacted>
0x194599c64 - /System/Library/PrivateFrameworks/TCC.framework/TCC : <redacted>
0x194599ba4 - /System/Library/PrivateFrameworks/TCC.framework/TCC : <redacted>
0x19459dad8 - /System/Library/PrivateFrameworks/TCC.framework/TCC : <redacted>
0x18df00b1c - /usr/lib/system/libxpc.dylib : <redacted>
0x18def53e8 - /usr/lib/system/libxpc.dylib : <redacted>
0x18dff35a4 - /usr/lib/system/libdispatch.dylib : <redacted>
0x18dfca0f8 - /usr/lib/system/libdispatch.dylib : <redacted>
0x18dfda1c0 - /usr/lib/system/libdispatch.dylib : <redacted>
0x18e044bac - /usr/lib/system/libsystem_pthread.dylib : _pthread_wqthread
0x18e047740 - /usr/lib/system/libsystem_pthread.dylib : start_wqthread

=================================================================

Basic Fault Address Reporting

Memory around native instruction pointer (0x18e1217f4):0x18e1217e4 c0 03 5f d6 c0 03 5f d6 30 41 80 d2 01 10 00 d4 ......0A......
0x18e1217f4 e3 00 00 54 fd 7b bf a9 fd 03 00 91 b4 80 ff 97 ...T.{..........
0x18e121804 bf 03 00 91 fd 7b c1 a8 c0 03 5f d6 c0 03 5f d6 .....{........
0x18e121814 d0 03 80 d2 01 10 00 d4 e3 00 00 54 fd 7b bf a9 ...........T.{..

XFC0009 when trying to extent Entry class with ICommand bindable property

$
0
0

Hello,
I have got a class which extends Entry to allow me to add a bindable property called 'Command' of type ICommand, but when I try to run the code I get error XFC0009 No property, bindable property, or event found for 'DisplayBinding', or mismatching type between value and property.

The extended Entry:

    class ExtendedEntry : Entry
    {
        public static readonly BindableProperty CommandProperty = BindableProperty.Create("Command", typeof(ICommand), typeof(ExtendedEntry));

        public ICommand Command
        {
            get { return (ICommand)GetValue(CommandProperty); }
            set { SetValue(CommandProperty, value);}
        }
    }

My XAML:

            <CustomViews:ExtendedEntry x:Name="entryTariff"
                                       Text="{Binding SelectedTariffName}"
                                       Command="EntryTariffSelectedCommand"/>

My ICommand property in my ViewModel which is the binding source for the entry's command:

        public ICommand EntryTariffSelectedCommand { get; set; }

        //Constructor
        public SettingsPageViewModel()
        {
            EntryTariffSelectedCommand = new Command( () => { this.SelectedTariffName = "Mooooooooooooooh!"; });
        }

My bindable property in my ExtendedEntry class is the same as in the solution by NMackay here:
https://forums.xamarin.com/discussion/88186/custom-control-with-icommand-property-not-working

Any pointers as to what I might be doing wrong?

Running Function from Task.Run gives infinite loop

$
0
0

have this function

private async Task<int> SearchForAllNumbers(int num = -1)
       {
           if (num == -1)
               DisplayLoadingMessage(true, GetString(Resource.String.Common_SearchTitle), GetString(Resource.String.Common_SearchMessage));
           dates = DateFunctions.GetSelectedDates(DateFrom, DateTo);

           var list = string.Empty;
           var klirwseis = ", Κληρωσεις: ";
           if (num == -1)
               list = ListTextView.Text;
           else
               list = num.ToString();
           var nums = list.Split(',').Select(Int32.Parse).ToList();
           if (seperateCheckBox.Checked)
           {
               DisplayLoadingMessage(false);
               seperateCheckBox.Checked = false;
               for (int k = 0; k < nums.Count; k++)
               {
                   await SearchForAllNumbers(nums[k]);
               }
               return -1;
           }
           var totalCoutner = 0;
           for (int datesPos = 0; datesPos <= dates.Count; datesPos++)
           {
              ... Do some calculations
               }
               HistoryTextView.Text = "Ημερομηνία: " + dates[datesPos] + ", Λίστα: " + list + ", Κληρώθηκε: " + totalCoutner + " φορές" + HistoryTextView.Text;
               if (showListsCheckBox.Checked)
                   HistoryTextView.Text = klirwseis + HistoryTextView.Text;
           }
           DisplayLoadingMessage(false);
           HistoryTextView.Text = ".\n" + HistoryTextView.Text;
           return totalCoutner;
           return 0;
       }

And i want to be able to cancel it when its running so i have created this function

private async Task SearchFoNumbersAsync()
        {
            ActiveCancellationTokenSource = new CancellationTokenSource();
            DrawResultsTypeEnum searchType = (DrawResultsTypeEnum)ShowResultsSpinnerPosition;

            var task = Task.Run(async () =>
            {
                if (searchType == DrawResultsTypeEnum.AllNumbers)
                    await SearchForAllNumbers();
                else if (searchType == DrawResultsTypeEnum.AnyWinningCombination)
                    await SearchAnyWinningCombination();
                SaveHistory();
            }, ActiveCancellationTokenSource.Token); // Pass same token to Task.Run.

            try
            {
                await task;
            }
            catch (System.OperationCanceledException e)
            {
                Console.WriteLine($"{nameof(System.OperationCanceledException)} thrown with message: {e.Message}");
                DisplayLoadingMessage(false);
            }
            finally
            {
                ActiveCancellationTokenSource.Dispose();
                DisplayLoadingMessage(false);
            }
        }

To be able to run it from Task.Run and to be able to cancel it. The code doesnt work however
I have debug it and when it reach the

try
            {
                await task;
            }

Stays there forever, the

SearchForAllNumbers()
or

SearchAnyWinningCombination()
are not accessed at all.
i'm not sure what i have done wrong.

Xamarin forms: Issue with Launching IOS App from Xamarin Forms App (Invalid input URL)

$
0
0

I am trying to open an ios app from my xamarin forms ios app. I have referred this thread for this feature, but I am getting error: "Invalid input URL" message on the output box.

Interface on Main project

public interface IAppHandler
{
    Task<bool> LaunchApp(string uri);
}

IOS

[assembly: Dependency(typeof(OpenAppImplementation))]
namespace Projectname.iOS.Renderer
{
    public class OpenAppImplementation : IAppHandler
    {
        public Task<bool> LaunchApp(string uri)
        {
            try
            {
                var canOpen = UIApplication.SharedApplication.CanOpenUrl(new NSUrl(uri));
                if (!canOpen)
                    return Task.FromResult(false);
                    return Task.FromResult(UIApplication.SharedApplication.OpenUrl(new NSUrl(uri)));
            }
            catch (Exception ex)
            {
                return Task.FromResult(false);
            }
        }
    }
}

Info.plist: App Bundle Identifier details added here.

enter image description here

In the view

ar appname = "App Bundle Identifier";
var result = await DependencyService.Get<IAppHandler>().LaunchApp(appname);
if (!result)
{
Device.OpenUri(new Uri("Appstore link"));
}

When I am trying to open the app I am getting 2020-09-05 13:41:30.761 ProjectName.iOS[1128:451468] -canOpenURL: failed for URL: "Bundle Identifier" - error: "Invalid input URL" on the output box. What I am missing in this implementation?

iOS - Will brand new Xamarin Developers fail to develop even a test project right now?

$
0
0

If you update your VS for Mac, Xamarin and Xcode to the latest, would a new developer get any joy right now? - I do not think so, I think they will all say Xamarin sucks and leave. Right now I can't get the VS debug/Device to ungrey out so I can pick a physical device, I have tried different cables and different fully updated iphones. You can get it to work on a simulator, but not on the device, and if you submit to apple store / test flight, it gets rejected by the apple folks, as the app crashes at the splash screen. This is happening to an existing app that was working just fine before any updates.
Microsoft page
https://docs.microsoft.com/en-us/visualstudio/releasenotes/vs2019-mac-relnotes#knownissues

Says "The stable channel build of Visual Studio for Mac does not support Xcode 12"

So basically any one new, updating latest everything is just screwed right? Correct me if am wrong? But what kind of message is this sending out?

I'd love to be corrected, anyone with more connections than I, can you verify this? or am I not doings something right?


Generated C# classes not nesting java classes correctly

$
0
0

I am trying to Bind the Poynt SDK to C# Using Xamarin's binding library. The .aar file is public for anyone who wants to recreate this

I am having a problem binding the .aar file, after building the solution the classes aren't being nested properly.

IPoyntProductCatalogWithProductListener is an interface that is supposed to contain a nested Stub class that contains a nested Proxy class. Instead the Stub and Proxy are outside of the interface.

I am following the java example app for reference, this is the code I am trying to replicate:

private IPoyntProductCatalogWithProductListener mProdCatWithProdListener = new IPoyntProductCatalogWithProductListener.Stub() {
    @Override
    public void onResponse(CatalogWithProduct catalogWithProduct, PoyntError poyntError) throws RemoteException {
        StringBuilder output = new StringBuilder();
        // products not nested inside a category
        for (CatalogItemWithProduct catalogItem : catalogWithProduct.getProducts()){
            Product product = catalogItem.getProduct();
            output.append("---- ITEM -----\n");
            output.append("Product Name: " + product.getName() + "\n");
            output.append("Product Id: " + product.getId() + "\n");
            output.append("Product Price: " + product.getPrice().getAmount() + "\n");
            Log.d(TAG, "\n"+output);
        }

}
};

As you can see I can't do "IPontProductCatalogWithProductListener.Stub" because it isn't nested. Is there a way I can edit the metadata file so it forces these nested classes. Or is there a work around?

Is it possible to return the value from SQLite database into the Entry (When the program starts)?

$
0
0

My database:

public class Kalorie
    {
        [PrimaryKey, AutoIncrement]
        public int Ilosc { get; set; }
        public DateTime Czas { get; set; }
        public int Teraz { get; set; }
    }

I wanted to return value from "Teraz" to Entry.

public Task<List<Kalorie>> GetTeraz()
{
    return _database.QueryAsync<Kalorie>($"SELECT Teraz FROM Kalorie;");
}
protected override async void OnAppearing()
        {
            base.OnAppearing();

            listView.ItemsSource = await App.Database.GetPeopleAsync();
            Entry2.Text = await App.Database.GetTeraz();       
        }

The assumption of the application is that the user enters the value "Entry1". This value is saved in the database in the "Teraz" field, and then when the user opens the application again, this value is loaded into "Entry2".

Set security on an offline app

$
0
0

Hello:

I made an application which simply do calculation, is completely offline, i would like to export the app in an apk file, but i don't know if it's safe.
Should i add something to keep in safe my app, or is it already safe as it is, without adding any security string?
Thank you.

Todo sample with authentication in local database

$
0
0

Hi done the first demo app ... classic todo list
but i have many difficult on how implement registration and login?
Im able to set Foreign key between item class and user but then i not sure on how persist credential of authenticated user
what the best way?
Please not sample with azure or other Rest request... i would offline authentication (im able to use password salt and hash because i know c# an intermediate level)

im new to xamarin please help

Checking IAP subscription status in an App?

$
0
0

Hello,

I have an IAP subscription that has a 14-day trial period.
Once the 14 days is up, the user is charged their first subscription payment.

The user can cancel their subscription at any time.

Each time the user starts the app, I need to check subscription status to see they have not cancelled subscription OR if they're installing on another device, restore the subscription on THAT device too.

Apparently, checking on purchases from the app requires the user to login to their app store account.

**Question **- Is that the case? By checking purchases in code, does the user need to login to the App Store?
I'm trying not to force the user to login each time they start the app...

**Question **- Using subscription IAP, does the purchase transaction date get updated in the app store each time the user is charged for the subscription?

I'm using Xamarin.Forms and InAppBillingPlugin

Thanks to those who can advise.

Here's the check/restore code:

    public async Task<bool> CheckOrRestoreSubscription()
    {
        var billing = CrossInAppBilling.Current;
        try
        {
            var connected = await billing.ConnectAsync(ItemType.Subscription);

            if (!connected)
            {
                //Couldn't connect
                return false;
            }

            var verify = DependencyService.Get<IInAppBillingVerifyPurchase>();

            //check purchases
            var purchases = await billing.GetPurchasesAsync(ItemType.Subscription, verify);

            //check for null just in case
            if (purchases?.Any<InAppBillingPurchase>(p => p.ProductId == Settings.ProductId) ?? false)
            {
                foreach(InAppBillingPurchase purchase in purchases) //there should only be one
                {
                    if(purchase.ProductId == Settings.ProductId)
                    {
                        Settings.SubscriptionToken = purchase.PurchaseToken;
                        Settings.ProductTransactionDate = purchase.TransactionDateUtc;

                        if (!purchase.AutoRenewing) //The item in AppStores set to AutoRenew. If false, user has cancelled
                        {
                            return false; //show Subscribe Screen
                        }
                        else
                        {
                            if(purchase.State == PurchaseState.Canceled || purchase.State == PurchaseState.Refunded || purchase.State == PurchaseState.Failed)
                            {
                                return false; //show Subscribe Screen
                            }
                            else
                            {   //App is still on trial OR user might have uninstalled/reinstalled the app or installed on another device
                                if (string.IsNullOrEmpty(Settings.SubscriptionToken))
                                {
                                    //Purchase restored or still in trial period
                                }
                            }
                        }
                    }
                }
                return true;    //Enable App Features
            }
            else
            {
                return false; //show Subscribe Screen
            }
        }
        catch (InAppBillingPurchaseException purchaseEx)
        {
            //Billing Exception handle this based on the type
            Debug.WriteLine("Error: " + purchaseEx);
        }
        catch (Exception ex)
        {
            //Something has gone wrong
        }
        finally
        {
            await billing.DisconnectAsync();
        }
        return false; //show Subscribe Screen
    }
}

Using Navigation Page & Tabbed Page For Multiple Hierarchical Page Navigation

$
0
0

So here's my dilemma. I was building a cross-platform app with Xamarin.Forms Shell, but it has some limitations for the grander scope of what my employer is trying to achieve, so I'm having to rebuild the core navigation.

In Shell, I used TabBar and simply declared all the pages with the Navigation Schema of Routing and then simply just had to call for Shell.GoToAsync() to navigate to each page from anywhere within the app itself.

In switching to TabbedPage, I'm having trouble getting the navigation to work. I get the error "PushAsync is not supported globally on Android, please use a NavigationPage" and the same error for iOS. So I can't get to any level beyond the child page of the TabbedPage itself.

This is the code I have for my StartPage

  <TabbedPage>
    <NavigationPage
      Title="Home" Style="{StaticResource BaseNavigationStyle}">
      <NavigationPage.IconImageSource>
          <FontImageSource
              FontFamily="{DynamicResource FontAwesomeSolid}"
              Glyph="{StaticResource HomeIcon}"
              Size="{StaticResource GlyphSize}"
              Color="White"/>
      </NavigationPage.IconImageSource>
      <x:Arguments>
          <page:HomePage />
      </x:Arguments>
  </NavigationPage>
  <NavigationPage x:Name="Items_Dashboard"
      Title="Items" Style="{StaticResource BaseNavigationStyle}">
      <NavigationPage.IconImageSource>
          <FontImageSource
              FontFamily="{DynamicResource FontAwesomeSolid}"
              Glyph="{StaticResource ItemsIcon}"
              Size="{StaticResource GlyphSize}"
              Color="White"/>
      </NavigationPage.IconImageSource>
      <x:Arguments>
          <page:ItemDashboard />
      </x:Arguments>
  </NavigationPage>
  <NavigationPage x:Name="Orders_Dashboard"
      Title="Orders" Style="{StaticResource BaseNavigationStyle}">
      <NavigationPage.IconImageSource>
          <FontImageSource
              FontFamily="{DynamicResource FontAwesomeSolid}"
              Glyph="{StaticResource OrdersIcon}"
              Size="{StaticResource GlyphSize}"
              Color="White"/>
      </NavigationPage.IconImageSource>
      <x:Arguments>
          <page:OrdersDashboard />
      </x:Arguments>
  </NavigationPage>
</TabbedPage>

So I'm doing what I believe was in the official docs about essentially wrapping each page in a NavigationPage, and on launch it works as expected, but when I try to link up a click from an object within any of the child pages, I get the error above.

Ultimately my navigation structure is something like this:
ALL NESTED WITHIN THE TABBEDPAGE
Home
-- Page 1 [MODAL]
-- Page 2 [MODAL]
-- Page 3 [MODAL]
Items
-- Page A
-- -- Page AA [MODAL]
-- Page B
-- -- Page BA
-- -- Page BB [MODAL]
-- Page C
-- -- Pace CA
-- -- Page CB
-- -- Page CC
-- -- -- Page CCA [MODAL]

So following this pattern, the user would tap on the Items Tab, then from a list on the displayed page they'd click and be taken to Page A, from where they can launch the Modal Page AA. All the while using the Back Arrow to navigate down the path as necessary.

In my App.cs code behind I'm doing this, because I want a LOGIN and LOADING screen depending on whether the user is logged in/out.

    protected override void OnStart()
    {
        State = new AppState();
        GetCurrentBarrels();
        LoadStyles();

        if (!string.IsNullOrWhiteSpace(State.ApiToken))
        {
            // Load to SplashScreen for background loading to avoid white space
            MainPage = NewLoadingPage();
            // Load Encryption Key;
            Barrel.EncryptionKey = State.ApiToken;
        }
        else
        {
            // If no token automatically drop user to login
            MainPage = NewLoginPage();
        }
    }
    public static NavigationPage NewLoginPage()
    {
        var page = new NavigationPage(new LoginPage());
        return page;
    }

    public static NavigationPage NewLoadingPage()
    {
        var page = new NavigationPage(new LoadingSplashPage());
        return page;
    }

Then from LOGIN or LOADING, I call for this:

    public static void ShowShell()
    {
        //Current.MainPage.Navigation.PopAsync();
        //Current.MainPage = _shell = new AppShell();
        Current.MainPage.Navigation.PopAsync();
        Current.MainPage = new StartPage();
    }

I've gone round and round with this, trying to figure out how to get it to work. If I wrap new StartPage() inside a new NavigationPage(), then I wind up with the Navigation Bar above the Navigation Bar of all my pages. I need the Navigation structure, but I don't want to lose my custom view that I'm implementing through a BasePage.

Does anyone have any ideas of either what I'm doing wrong? or how to deal with navigation and TabbedPage?

Tabbed application navigation with dependency injection

$
0
0

I've created a NavigationService which uses a navigation page to navigate around my app. I can PushAsync(page) but when I PopAsync() the navigation stack for the page doesn't decrement and the current page isn't removed from view. I'm using a tabbed application and implemented dependency injection with MVVM architecture.

I've tried running this on the UI thread and still no luck, out of ideas. Any help would be massively appreciated.


How can I bind text property of label to a sub/function value

$
0
0

Hi all,

I am very new to Xamarin, but very familiar with C#. What I am trying to do is get the value of sub routine in the cs file in my project and display it as the label text. Right now the routine is just returning some string value. The ultimate goal of this is to have the sub get the IP addy and display that value in the label text. I am trying to learn in little chunks, so getting the IP addy is a bit down the road.

I have been through a lot of iterations of this, nothing has worked so far, so what I have here might be very far from the mark:

From MainPage.xml:

        <Label
            x:Name="label3"
            Text="Some Text"
            />

From MainPage.xml.cs:

    private void SomeText(object sender, EventArgs e)
    {
        display = "Somemore Text";
        label3.Text = display;
    }

display is declared earlier in the MainPage,xml.cs file so that isn't causing an issue.

I have had bindings statements in and out, made the C# code above a function with a return value, made the sub public, etc. There are holes in the walls all over the house from banging my head against them.

Any hints on how to make this work would be greatly appreciated.

This is an app I am developing for learning how to create Android apps. I have a really usable app in mind for the company for which I work, but I need to know how to build apps before I jump into that project.

If someone can recommend a good Xamarin book, I would use that also. I prefer a physical book. I am old school that way.

Thanks bunches.

Bruce

Delete this post

$
0
0

Delete this post. I answered my own question.

Thanks

Does Xamarin have Its Own Web Server

$
0
0

I have an existing web page which uses the Tesseract.js OCR library and because of this it needs to run in some kind of web server such as Express or Live Server. I am planning to convert this web page into a web app but my concern is whether Xamarin has a built-in web server.

Accessing Switch in BluetoothReciever class and turn it off or on

$
0
0

Am trying to detect external Bluetooth trigger on event and toggle switch on in my application. i have the BluetoothReceiver below. i Just want that when the user swipes down the screen and enables bluetooth, my application reads that and "auto" toggles a switch accordingly
here is my code, when i try to use the var switch=this.findByName....Compiler reports that FindByname is not applicable in BluetoothReceiver class

[Android.Content.BroadcastReceiver]
[IntentFilter(new[] { Android.Bluetooth.BluetoothAdapter.ActionStateChanged })]
public class BluetoothStateChangedReceiver : BroadcastReceiver
{

public override void OnReceive(Context context, Intent intent)
{
    if (intent.Extras == null)
        return;

    var state = intent.GetIntExtra(Android.Bluetooth.BluetoothAdapter.ExtraState, -1);

    switch (state)
    {
        case (int)State.On:
            // bluetooth is on so toggle the switch on


            break;
        case (int)State.Off:
            // bluetooth is off so toggle the switch off

            break;
    }
}

}
Thanks In Advance

iOS 'Library' folder using Xamarin.iOS?

$
0
0

https://docs.microsoft.com/en-gb/xamarin/ios/app-fundamentals/file-system
according to this document, the below code returns the Libary path.

var docsPath = Environment.GetFolderPath (Environment.SpecialFolder.MyDocuments);
var libPath = Path.Combine (docsPath, "..", "Library");

My question is the Library folder is not a child of Documents, it's on the same level, why should it be concatenated?

Viewing all 204402 articles
Browse latest View live


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