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

MVVM Design Question

$
0
0

I'm designing an app and trying to follow MVVM as much as I can with this one.

I currently have an OrderPage with an OrderViewModel

The OrderPage Has 3 ConentView's:
HeaderView
AddressesView
ProductsView

With a status bar showing which is Active/Inactive/Complete.

The OrderViewModel contains Properties for HeaderViewModel, AddressesViewModel and ProductsViewModel.

Each view in OrderPage is bound to the corresponding ViewModel Property in OrderViewModel

OrderPage contains a "Save and Continue" button which basically determines which View to show while calling a save method in each view model.

My question is, is having nested ViewModels a viable solution with MVVM or would it be better to make each ViewModel have it's own content page?


Can't paste text into entry (IOS emulator)

$
0
0

Hi, I have some entries and editors in my app, but I can't paste anything into it.

I tried using command+v and by using the menu, but every time I just get a notice at the top of the screen saying "pasted from Safari", but nothing is displayed in the entry or editor.

I can still paste into safari, so it must have something to do with Xamarin. Here is my code:

Thanks for your help!

Xamarin.Forms: Accessing external storage on Android 11 (target sdk version is 29)

$
0
0

I have an App that has to access external storage (logs, SQLite), and it stopped working (on Android >= 10) since I updated it to Android 10. I found a workaround to set

android:requestLegacyExternalStorage="true"

and it works fine on Android 10 now, but not on Android 11. I heard that this should still work on Android 11 if my app is targeting android 10 (SDK 29), so in my case, it should work. But it doesn't, and I still get deployment failed, permission denied. Anyone already came across this issue?

Floating action button at the bottom of the xaml page

$
0
0

How to add a Floating Action Button At the Bottom of the page...Please anyone suggest me how to do it?

How to get audio file locations?

$
0
0

I am trying to get locations of audio files in Xamarin.Forms. I am currently using resources to play audio file, I put there myself, but want to search the phone for these files and save in a List with its locations?

How to transition moves the refresh content and main content simultaneously in Xamarin Form

$
0
0

Hi All,
I'm using refresh view above scrollview, in iOS it work fine but in android I want I act like transition moves the refresh content and main content simultaneously. Like this what I want in android as well

visual studio 2019 (community): how to disable storage clear data for my installed app?

$
0
0

Hiiiiiiiiiii

I designed an app that I published in the google play store
The app uses a local database to enable the user to register once and use the app for a limited period of 1 year only.
But...
the problem is that when a user installs my app, he can easily go to the settings of his Android phone, click on Apps
then look for the installed app
and click on Storage

and
Clear All Data
stored in the local database

by doing so, he will be able to use it again as if it is the first time.

So the trial period is useless in this case

HOW to disable the "Clear All Data" in the storage?

Please help

CarouselView how to swipe only one element at a time

$
0
0

I need a horizontal carousel showing only one element at a time in the page, and also when swiping from one element to the other. Is it possible by means of CarouselView? Suggestions?

This is my actual code:

<CarouselView AbsoluteLayout.LayoutFlags="All" AbsoluteLayout.LayoutBounds="0,0,1,1"
    ItemsSource="{Binding Homes}" ItemTemplate="{StaticResource HomeTemplate}"
    PeekAreaInsets="0" IsSwipeEnabled="True" Loop="False" IsScrollAnimated="False" ItemsUpdatingScrollMode="KeepItemsInView" HorizontalScrollBarVisibility="Never" VerticalScrollBarVisibility="Never">
    <CarouselView.ItemsLayout>
        <LinearItemsLayout Orientation="Horizontal" ItemSpacing="0"  />
    </CarouselView.ItemsLayout>
</CarouselView>

How to get data files folder in Xamarin.Forms

$
0
0

Hello,

I need to show a video file in Xamarin.Forms. I have placed the MP4 file in \Internal storage\Android\data\com.mycompany.MyApp\files\Videos

Then, I tried to access it using:

string videoPath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyVideos), this.viewModel.Item.Video)

But videoPath variable contains "/data/data/com.desytec.FinningApp/files/Videos/777.mp4" .

Then, I am checking file existence:

bool existing = System.IO.File.Exists(videoPath);

But "existing" returns false. I tried by changing the first "/data" to "/Android" but the file is not found either.

Any help, please?

Thanks
Jaime

Can't access view from code behind

$
0
0

Hi everyone, I'm trying to access the following labels (1 and 2) from cs code behind but for some reason I can't.

Keep in mind that both labels have their x:Name propery set, and even their field modifier.

I'll appreciate a lot all the help that you could provide.

XF 4.8 SwipeView in DataTemplate for ListView

$
0
0

Hi all,
Just tried to use the (experimental in 4.8) SwipeView in an ItemTemplate, wrapping the cell contents in a ListView.
Is it me or is it dreadfully slow? The ListView takes much longer to load on iOS even with recycle enabled.

Also, it doesn't appear to work at all for UWP, am I missing something?

I can put together an example if required, in the mean time Ive gone with a context menu, which is just about ok but not very customisable.

Cheers
John

Tab Navigation Delay

$
0
0

I have been researching and digging in and I heard @DavidOrtinau say in a .net MAUI presentation that there some lag in the tab navigation and page loading currently in Xamarin. I have a shell app, with tabs and I can click on the tab, count one thousand, two thousand and then the tab opens.
Dave said the more includes and references you have on your pages it can bog down on initial load. I am trying to find out how to either get a busy spinner as soon as I click the tab or load the tab faster. I am not entirely sure how. I think part of the issue is the 3rd party controls I am using, Syncfusion. Any comments or ideas would truly be appreciated.

Styling with OnIdiom and AbsoluteLayout

$
0
0

I am trying to create a style for a circular frame that adjust its size using OnIdiom.

Here is the code:

`<Style TargetType="Frame" x:Key="CircleFrameRight">
            <Setter Property="AbsoluteLayout.LayoutBounds">
                <Setter.Value>
                    <OnIdiom x:TypeArguments="Rectangle" Phone=".85,.8, 80, 80" Tablet=".85,.8, 120, 120"/>
                </Setter.Value>
            </Setter>
            <Setter Property="CornerRadius">
                <Setter.Value>
                    <OnIdiom x:TypeArguments="x:Double" Phone="40" Tablet="60"/>
                </Setter.Value>
            </Setter>
        </Style>`

I get an error saying "No Property, BindableProperty, or event found for "Phone" or mismatching type between value and property. Thank you!

No Launchable Activity: This project does not contain any activities marked MainLauncher. It has bee

$
0
0

After updating Visual Studio Community 2019 to 16.6.0 i am getting this error help me please :
No Launchable Activity: This project does not contain any activities marked MainLauncher. It has been deployed to the device, but no activity will be launched.

To mark an activity as launchable, add the [Activity] attribute to it with MainLauncher = true:

[Activity (MainLauncher = true)]
public class MyActivity : Activity

Any way to trace unhandled exceptions easily?

$
0
0

I try to use try catch statements everywhere appropriate, but sadly there are places in my code that are unhanded.
The problem is that once I get to one of these exceptions, all I get is Unhandled exception and the code reference is [External code]. I know the general area of code that it is occurring in but the crash is part of a race condition, and only intermittent so locating the place is going to be difficult. If I could trace the stack I could find it easier.

Any ideas?


How to set title for marker using MarkerOptions for each annotation in MapView?

$
0
0

I have added each marker like below:

 var marker = new MarkerOptions();
 marker.SetTitle(annotation.Title);
 marker.SetSnippet(annotation.SubTitle);
 marker.SetPosition(annotation.MarkerCoordinate.ToLatLng());
 marker.SetIcon(IconFactory.GetInstance(Context).DefaultMarker());

My problem - the text i have given for SetTitle does not display on the marker. Do miss something. Why title does not display on the marker?
Can anyone help me please....

Currently am checking in android. If you have any idea for both Android & iOS, it will very helpfull.

Tabbed Page selected tab using PRISM

$
0
0

Hello,
does anyone know how to get information about which tab is selected in a tabbed page?
CurrentPageChanged Event is only fired once when the tab-page is beeing loaded. Nothing happens when selecting Tabs.
using prism, how do I get INavigationAware with all OnNav... methods to work in tab page children pages?

No activity found to handle intent: How to handle activities accross multiple projects?

$
0
0

Greetings,

I am currently working on an app belonging to my company. The app is in two projects, one MVVM and the other the actual app. The actual app does nothing beyond start things, and the MVVM takes over for about everything else.

I've been trying to find a way to update the device, with little success currently. I've finally managed to make sure the device can find the file on the network, but I cannot get it to start the APK. Here's the relevant code.

public async static Task<bool> UpdateToServerVersion()
        {
            bool returnValue = false;
            await Task.Run(() =>
            {
                try
                {
                    SharpCifs.Config.SetProperty("jcifs.smb.client.lport", "8080");
                    string path = @"smb://Server/Share/IT/Androids/Picking.apk";
                    var auth = new NtlmPasswordAuthentication("Domain", "Login", "Password");
                    //Get target's SmbFile.
                    var file = new SmbFile(path, auth);
                    //Check if file exist
                    if (file.Exists())
                    {
                        Intent PromptInstall = new Intent(Intent.ActionView).SetDataAndType(Android.Net.Uri.Parse(file.GetPath()), "application/vnd.android.package-archive");
                        PromptInstall.SetFlags(ActivityFlags.GrantReadUriPermission);
                        PromptInstall.SetFlags(ActivityFlags.NewTask);
                        Android.App.Application.Context.StartActivity(PromptInstall);
                    }
                    else
                    {
                        returnValue = false;
                    }
                }
                catch(Exception e)
                {
                    Console.WriteLine(e.ToString());
                    returnValue = false;
                }
            });
            return returnValue;
        }

When it comes to the two projects, here is an image to show what it looks like:

The code shown above is within the "Helpers => common" from the Picking project, whereas the MainActivity is in Picking.Android. I presume the error I have is to do with it and prevent me from starting the intent.

Finally, here's the error returned when I try to run the code above:

No Activity found to handle Intent { act=android.intent.action.VIEW dat=smb://Domain/Share/IT/Androids/Picking.apk typ=application/vnd.android.package-archive flg=0x10000000 }01-19 17:16:22.236 I/mono-stdout(12860): Android.Content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=smb://Domain/Share/IT/Androids/Picking.apk typ=application/vnd.android.package-archive flg=0x10000000 }

at Java.Interop.JniEnvironment+InstanceMethods.CallVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x0006e] in :0
at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x0002a] in :0
at Android.Content.ContextWrapper.StartActivity (Android.Content.Intent intent) [0x00031] in :0
at Picking.Helpers.Common+<>c__DisplayClass46_0.b__0 () [0x00077] in D:\cldRefactoring\cldRefactoring\Projects\1 Presentation\Picking-4.0\Picking\Picking\Helpers\Common.cs:937
--- End of managed Android.Content.ActivityNotFoundException stack trace ---
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=smb://nascld/Share/IT/Androids/Picking.apk typ=application/vnd.android.package-archive flg=0x10000000 }
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1816)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1525)
at android.app.ContextImpl.startActivity(ContextImpl.java:791)
at android.app.ContextImpl.startActivity(ContextImpl.java:768)
at android.content.ContextWrapper.startActivity(ContextWrapper.java:356)

Thank you for your help and have a nice day

Static class not recognized by XAML even with the correct namespace

$
0
0

I am trying to use Material Design Icons as FontImageSource defined in a ResourceDictionary. However, I am getting "Type MaterialIcon not found in xmlns clr-namespace:TestProject".

Any advice in fixing this?

How to give Permission for Camera used in iOS App with Xamarin forms.

$
0
0

Hi , I need to used Camera and Photos in my App . I am using Xamarin forms.
Camera and Photos Library Access working fine in Android App . But not in iOS App.
is There anyone know , how can i used Camera and Photos for iOS App?

Thanks !!

Viewing all 77050 articles
Browse latest View live


Latest Images

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