Hi,
I have used Zxing.Net.Mobile for barcode scanning . But I found when using with MVVM pattern & scanner view page, performance & result is not good.
Any tips to improve the performance or any good alternative libraries.
Regards
Ajit
Hi,
I have used Zxing.Net.Mobile for barcode scanning . But I found when using with MVVM pattern & scanner view page, performance & result is not good.
Any tips to improve the performance or any good alternative libraries.
Regards
Ajit
I want create SQLite DB when application is opened first time or when DB does not exist. How can i do that?
``` string fileName = "recommendList.db"; string folderPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal); public static string completePath; public App() { InitializeComponent(); //MainPage = new MainPage(); MainPage = new masterDetailPage(); completePath = Path.Combine(folderPath, fileName); } protected override void OnStart() { using (var db = new SQLiteConnection(completePath)) { if (!System.IO.File.Exists(completePath)) { } else { } } }
```
c# code-
protected override void OnElementChanged(ElementChangedEventArgs args)
{
base.OnElementChanged(args);
if (args.NewElement != null) { if (Control == null) { // Save the VideoView for future reference videoView = new VideoView(Context); // Put the VideoView in a RelativeLayout AWR relativeLayout = new AWR(Context); relativeLayout.AddView(videoView); // Center the VideoView in the RelativeLayout var layoutParams = new AWR.LayoutParams(Convert.ToInt32(DeviceDisplay.MainDisplayInfo.Width), Convert.ToInt32(DeviceDisplay.MainDisplayInfo.Height)); layoutParams.AddRule(LayoutRules.AlignParentTop); layoutParams.AddRule(LayoutRules.AlignParentBottom); layoutParams.AddRule(LayoutRules.AlignParentLeft); layoutParams.AddRule(LayoutRules.AlignParentRight); videoView.LayoutParameters = layoutParams; // Handle a VideoView event videoView.Prepared += OnVideoViewPrepared; SetNativeControl(relativeLayout); } SetAreTransportControlsEnabled(); PlayVideo(); args.NewElement.UpdateStatus += OnUpdateStatus; args.NewElement.PlayRequested += OnPlayRequested; args.NewElement.PauseRequested += OnPauseRequested; args.NewElement.StopRequested += OnStopRequested; } if (args.OldElement != null) { args.OldElement.UpdateStatus -= OnUpdateStatus; args.OldElement.PlayRequested -= OnPlayRequested; args.OldElement.PauseRequested -= OnPauseRequested; args.OldElement.StopRequested -= OnStopRequested; } }
Hi Forum,
I'm trying to override text color and background color for Shell.Flyout menu items. I'm targeting the default template from visual state manager but this is only working for 'Normal' state and not for 'Selected'. Any help?
<Style TargetType="Grid"> <Setter Property="VisualStateManager.VisualStateGroups" TargetName="FlyoutItemLayout"> <VisualStateGroupList> <VisualStateGroup x:Name="CommonStates"> <VisualState x:Name="Normal"> <VisualState.Setters> <Setter Property="Label.TextColor" Value="Red" TargetName="FlyoutItemLabel"/> </VisualState.Setters> </VisualState> <VisualState x:Name="Selected"> <VisualState.Setters> <Setter Property="BackgroundColor" Value="Blue" /> </VisualState.Setters> </VisualState> </VisualStateGroup> </VisualStateGroupList> </Setter> </Style>
And how can i target the color for the icon. I'm using FontImageSource for Flyout.Icon
<FlyoutItem Title="Pickers"> <FlyoutItem.Icon> <FontImageSource Glyph="" FontFamily="FontAwesome" Color="Gray"/> </FlyoutItem.Icon> <ShellContent ContentTemplate="{DataTemplate local:PickersPage}"/> </FlyoutItem>
Sometimes i am getting this error.
System.ArgumentNullException: 'Value cannot be null.
Parameter name: targetObject'
I send a parameter from view using button:
public async void btnchat_clicked(object sender, EventArgs e)
{
string sellerid = custid.Text;
await Navigation.PushAsync(new ChatPageViewModel(sellerid.ToString()));
}
i need help for how to receive the value in viewmodel for where clause
I'm having issues building on iOS after my Windows version of Visual Studio was updated. My Windows system is running Xamarin.iOS 1.4. but my iMac has only Xamarin.iOS 14.0. Auto update on the iMAC tries to install 14.6 but just says 'Failed' with no details. If I try to install 14.4 from Visual Studio on the PC this also just fails with no details.
I have been using Xamarin for a few years now and its this sort of thing which frustrates more than anything. Things just go out of sync for a while and I spend ages trying to unravel what's going on. When I build with this mis-match I get an 'unknown command line argument' reported hundreds of times.
Hello,
I'm heading strange situation on iPhone 11 iOS 14.1 (simulator and device). I've got simple ListView. When in portrait everything looks fine, but landscape mode is strange margin. I assume that this is padding iside listview or margin on cellview cells.
Question is how to get rid of it.
My code is very siple:
`
<Grid Margin="0,40,0,0" BackgroundColor="Yellow"> <Grid.RowDefinitions> <RowDefinition Height="30"/> <RowDefinition Height="*"/> </Grid.RowDefinitions> <Label Grid.Row="0" Text="Welcome !!!"/> <ListView x:Name="list" Grid.Row="1" BackgroundColor="Green" HorizontalOptions="FillAndExpand"> <ListView.ItemTemplate> <DataTemplate> <ViewCell> <Grid BackgroundColor="Red" HeightRequest="30"> <Label Text="{Binding .}"/> </Grid> </ViewCell> </DataTemplate> </ListView.ItemTemplate> </ListView> </Grid>
`
I am trying to implement the following layout structure using Xamarin Forms components:
- ScrollView (which displays a sticky header when scrolling) - Title & body text - Tab Switching Component - Tab 1: CollectionView of items (load new items on ItemThresholdReached) - Tab 2: CollectionView of items (")
The desired behaviour is that when scrolling down either of the CollectionViews, the content above this (the text and tab switcher) should scroll out of view and be hidden by the sticky header. Upon scrolling back to the top of the collection view, it would scroll to the top of the page, revealing the content at the top and the sticky header would hide. Essentially, the Collection View and header content should scroll together as one scrolling view. With the above structure, the scroll isn't working because these CollectionViews are inside of an outer ScrollView.
I am using Collection View elements here because I am utilising the ItemThresholdReachedCommand to efficiently load more elements to the collection. The length of the collections will potentially be in the hundreds so performance is also important.
So far I have tried the following:
I set the header content as the header element of the Collection Views so that they would scroll as one. However this doesn't work because the header content is shared by both collection views, including the tab switcher component which wraps both Collection Views. Therefore this content cannot be placed into Collection View header elements.
I have also tried using a BindableLayout instead of CollectionView but this has none of the built-in events that Collection View has and I have read that Bindable Layout shouldn't be used for larger lists of items.
If anyone has any advice on the best way of trying to achieve this, it would be much much appreciated. At this point it feels impossible in Xamarin Forms!
Hello together
I have the problem that the binding which I set for the selecteditem of the picker will not change when the variable behind has changed.
xml of the picker:<Picker ItemsSource="{Binding TeamListe}" SelectedItem="{Binding SelectedItem}" />
The code of the viewmodel
static string _SelectedItem; public string SelectedItem { get { return _SelectedItem; } set { _SelectedItem = value; OnPropertyChanged("SelectedItem"); } }
When I set the value on appearing it works.
But when I ty to change the selecteditem as an example when I clicked on a button it does not work.
Other bindings like the ItemSource of a Listview in the same project do work.
What do I miss?
Thanks for your help.
Regards
When I use '?' operator for a event or listener, on debug mode works fine but when I generate release versión, apps does not work.
When execute this line of code app breaks
event?.Invoque(parameters)
I have to use:
if(event != null) { event.Invoque(parameters) }
Any idea?
Thanks
Hello everyone,
I have been using a process for applying themes to my app that involves just merging a class I created in XML to the resource dictionary.
Here is the code I have been using
in App.xaml.cs
/// <summary> /// Switch the theme from light to dark or vice versa. /// </summary> public static void ChangeTheme() { // check if the theme key exists, if not default it to the light theme. if (!AppSettingsFunctions.CheckKey("App_Theme")) { AppSettingsFunctions.SaveSettingData("App_Theme", 0); } var theme = AppSettingsFunctions.GetSetting("App_Theme"); if (string.IsNullOrEmpty(theme.ToString())) { theme = Theme.Light; } var themeChoice = Convert.ToInt32(theme, CultureInfo.InvariantCulture); var currRess = Current.Resources; switch (themeChoice) { case (int)Theme.Dark: currRess.MergedWith = typeof(Themes.DarkThemeDictionary); break; case (int)Theme.Light: currRess.MergedWith = typeof(Themes.LightThemeDictionary); break; case (int)Theme.Colorful: currRess.MergedWith = typeof(Themes.ColorfulThemeDictionary); break; default: currRess.MergedWith = typeof(Themes.LightThemeDictionary); break; } }
in Themes/LightTheme.xml
<?xml version="1.0" encoding="utf-8" ?> <ResourceDictionary x:Class="MyApp.Themes.LightThemeDictionary" xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:local="clr-namespace:MyApp.Themes"> <local:DgStyleLight x:Key="dgStyle" /> <x:String x:Key="icoKeyImage">ic_key_image.ico</x:String> <x:String x:Key="icoFilter">ic_filter.ico</x:String> <x:String x:Key="icoEditFilter">ic_filter_edit.ico</x:String> <x:String x:Key="icoClearFilter">ic_filter_clear.ico</x:String> <x:String x:Key="icoRemoveImage">ic_remove_image.ico</x:String> <x:String x:Key="icoSMS">ic_sms.ico</x:String> <x:String x:Key="icoSortFilter">ic_filter_sort.ico</x:String> <x:String x:Key="icoForm">ic_form.ico</x:String> <Color x:Key="primary-back-title-color">#888888</Color> <Color x:Key="primary-title-color">#271214</Color> <Color x:Key="NavigationPrimary">#778899</Color> <Color x:Key="AppBackgroundColor">#A1A1A1</Color> <Color x:Key="cMenuItemAccentColor">#492C2D</Color> <Color x:Key="cMenuitemSeparator">#494949</Color> <Color x:Key="cMenuMainBackgroundColor">#9D9FA0</Color> <Color x:Key="cBorderColor">#829581</Color> <Color x:Key="cShadowColor">#325430</Color> <OnPlatform x:Key="FontIcons" x:TypeArguments="x:String"> <OnPlatform.Platforms> <On Platform="Android" Value="UIFontIcons.ttf#UIFontIcons" /> <On Platform="iOS" Value="UIFontIcons" /> <On Platform="UWP" Value="Assets/UIFontIcons.ttf#UIFontIcons" /> </OnPlatform.Platforms> </OnPlatform> <OnPlatform x:Key="Baloo2-ExtraBold" x:TypeArguments="x:String"> <OnPlatform.Platforms> <On Platform="Android" Value="Baloo2-ExtraBold.ttf#Baloo2-ExtraBold" /> <On Platform="iOS" Value="Baloo2-ExtraBold" /> <On Platform="UWP" Value="Assets/Baloo2-ExtraBold.ttf#Baloo2-ExtraBold" /> </OnPlatform.Platforms> </OnPlatform> </ResourceDictionary>
From my understanding the MergeWith
field is being deprecated, and replaced with Source
.
The problem I have is the only way I can think of addressing this is to manually make a URI to the XML file, and apply it there.
Eg;
Uri path; Uri.TryCreate("Theme/ColorfulTheme.xml", UriKind.Relative, out path); currRess.Source = path;
But this code throws an exception saying that the source field can only be edited by XAML code. I'm also not entirely sure that this would work as I am not sure the URI understands the code to be based on the Project file, and not some files on the filesystem (I suppose I could copy the files to the app folder/files in a pinch if that's what needed)
Is there some way to continue to apply the resource directories dynamically from within the C# code?
For the time being I'm just ignoring the warning, but would like to try to fix this so it doesn't cause problems later.
Thanks for any ideas!
Is there any other better way to terminate Xamarin Forms App ? Than this ?
In Main Project PCL
protected override bool OnBackButtonPressed() { Device.BeginInvokeOnMainThread(async () => { var result = await this.DisplayAlert("Alert!", "want to exit?", "Yes", "No"); if (result) { var closer = DependencyService.Get<ICloseApplication>(); closer?.closeApplication(); } }); return true; }
public interface ICloseApplication { void closeApplication(); }
[assembly: Xamarin.Forms.Dependency(typeof(CloseApplication))] namespace XForms.Droid { public class CloseApplication : ICloseApplication { public void closeApplication() { Android.OS.Process.KillProcess(Android.OS.Process.MyPid()); } } }
[assembly: Xamarin.Forms.Dependency(typeof(CloseApplication))] namespace XForms.Droid { public class CloseApplication : ICloseApplication { public void closeApplication() { Thread.CurrentThread.Abort(); } } }
I'm converting an app to use FreshMVVM from a non-MVVM format. When the app launches, there is a login page, then after login, a tabbed page with modal pages called from the buttons on each tabbed page.
Given the process I'm following, I figured that this would be a perfect option to use @MichaelRidland 's process to switch out NavigationStacks
(github rid00z/FreshMvvm#switching-out-navigationstacks-on-the-xamarinforms-mainpage), but the steps appear to be missing quite a few important instructions, and these steps are not in the sample app on the GitHub.
In my App.xaml.xs file, I have the following code:
public App() { InitializeComponent(); var loginPage = FreshMvvm.FreshPageModelResolver.ResolvePageModel<LoginPageModel>(); var loginContainer = new STNavigationContainer(loginPage, NavigationContainerNames.AuthenticationContainer); var homePageViewContainer = new FreshTabbedNavigationContainer(NavigationContainerNames.MainContainer); MainPage = loginContainer; } public FreshTabbedNavigationContainer(string navigationServiceName) { NavigationServiceName = navigationServiceName; RegisterNavigation(); } protected void RegisterNavigation() { FreshIOC.Container.Register<IFreshNavigationService>(this, NavigationServiceName) } public void SwitchOutRootNavigation(string navigationServiceName) { IFreshNavigationService rootNavigation = FreshIOC.Container.Resolve<IFreshNavigationService>(navigationServiceName); } public void LoadTabbedNav() { var tabbedNavigation = new FreshTabbedNavigationContainer(); tabbedNavigation.AddTab<CharactersPageModel>("Characters", "characters.png"); tabbedNavigation.AddTab<AdventuresPageModel>("Adventures", "adventures.png"); tabbedNavigation.AddTab<AccountPageModel>("Account", "account.png"); MainPage = tabbedNavigation; } public class NavigationContainerNames { public const string AuthenticationContainer = "AuthenticationContainer"; public const string MainContainer = "MainContainer"; }
I have extended the FreshNavigationContainter
class and the FreshNavigationPage
class. Here are my extended classes:
STNavigationContainer:
public class STNavigationContainer : FreshNavigationContainer { public STNavigationContainer(Page page) : base(page) { } public STNavigationContainer(Page page, string navigationPageName) : base(page, navigationPageName) { } protected override Page CreateContainerPage(Page page) { if (page is NavigationPage || page is MasterDetailPage || page is TabbedPage) return page; return new STNavigationPage(page); } }
STNavigationPage:
public class STNavigationPage : NavigationPage { public STNavigationPage() { } public STNavigationPage(Page page) : base(page) { BarBackgroundColor = Color.FromHex("#2DAFEB"); BarTextColor = Color.FromHex("#C9371D"); } }
This seems to match with the steps provided in the ReadMe.md, but the calls to NavigationServiceName
return an error, since there's no instruction on creating such a class or what it should contain, nor am I clear on where the FreshTabbedNavigationContainer
or SwitchOutRootNavigation
would be called.
Has anyone been able to get this to work? What steps am I missing on this?
I'm trying to implement ads in my app, and eventually in-app purchases (to register a full version upgrade from free)
I've been following the tutorial from this site
https://www.c-sharpcorner.com/article/google-admob-display-ads-in-xamarin-forms/
I've created my AdMob Account, and added my app, I have the adUnitID, and from what I can tell that part is completed properly.
The problem I am having is when I try to compile the code, I get missing AndroidX assemblies,
Here is the specific error I am getting
Could not find 8 Android X assemblies, make sure to install the following NuGet packages: - Xamarin.AndroidX.Lifecycle.LiveData - Xamarin.Google.Android.Material - Xamarin.AndroidX.Legacy.Support.V4
(Please note it says 8 but only lists 3 assemblies)
I've tried installing those assemblies. Once they are installed I get two errors when I try to build.
one is 1>C:\Users\jesse\OneDrive\Documents\Source\...\obj\Debug\90\lp\124\jl\res\values\values.xml(1778): error APT2000: expected enum but got (raw string) slide.
Which is this line in the code
<item name="animationMode">slide</item>
And the other error is 1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\Android\Xamarin.Android.Aapt2.targets(164,3): error APT2062: failed linking references.
This is the linking reference it refers to.
<Aapt2Link Condition=" '$(_AndroidResourceDesignerFile)' != '' And '$(_AndroidUseAapt2)' == 'True' " ContinueOnError="$(DesignTimeBuild)" DaemonMaxInstanceCount="$(Aapt2DaemonMaxInstanceCount)" DaemonKeepInDomain="$(_Aapt2DaemonKeepInDomain)" ResourceNameCaseMap="$(_AndroidResourceNameCaseMap)" AssemblyIdentityMapFile="$(_AndroidLibrayProjectAssemblyMapFile)" ImportsDirectory="$(_LibraryProjectImportsDirectoryName)" UseShortFileNames="$(UseShortFileNames)" OutputImportDirectory="$(_AndroidLibrayProjectIntermediatePath)" OutputFile="$(ResgenTemporaryDirectory)\resources.apk" PackageName="$(_AndroidPackage)" ApplicationName="$(_AndroidPackage)" JavaPlatformJarPath="$(JavaPlatformJarPath)" JavaDesignerOutputDirectory="$(ResgenTemporaryDirectory)" CompiledResourceFlatFiles="@(_CompiledFlatFiles)" ManifestFiles="$(ResgenTemporaryDirectory)\AndroidManifest.xml" AdditionalAndroidResourcePaths="@(_LibraryResourceDirectories)" YieldDuringToolExecution="$(YieldDuringToolExecution)" ResourceSymbolsTextFile="$(IntermediateOutputPath)R.txt" ResourceDirectories="$(MonoAndroidResDirIntermediate)" ExtraArgs="$(AndroidAapt2LinkExtraArgs)" ToolPath="$(Aapt2ToolPath)" ToolExe="$(Aapt2ToolExe)" UncompressedFileExtensions="$(AndroidStoreUncompressedFileExtensions)" ProguardRuleOutput="$(_Aapt2ProguardRules)" />
If I change the SDK version to Android10, all of the errors go away, the package gets deployed, but will not show up in the app launcher, and will not start when I try to debug it.
I'm terrified at what it's going to be like to add the in app purchase for my app... (actually just considering making a separate app in the store and making a new build target / alternate code base to build it from)
Please, there has to be some way to implement ads in a Xamarin.Forms app, that supports Android 9...
Anyone who's implemented AdMob to a Xamarin.Forms app (I don't even care if it supports iOS for now. I would be nice for the future, but for now I just want to get my Android app up and running)
Please help!?
I am working on a project where I need to Implement CoverFlow with Three images in left right and centre.
I really don't understand how the coverflow view can be implmented in xamarin forms, can anybody help me out?
Hey guys, I'm working on a Xamarin.Forms app that will use a carousel to display a collection of images. I'm using the Alliance Carousel (https://components.xamarin.com/view/Alliance.Carousel) in a custom renderer on iOS and everything is working great. I'm having a hard time finding anything that I can use on Android in a similar way. I know about the ViewPager option, as well as the Carousel control in XLabs. What I'm really looking for is a way to implement a coverflow like control in Android. Has anyone ever done something similar? If so please let me know what you used.
Hi I am looking for coverflow/carousel view for xamarin form.I will try for renderer but In android I did not get any help(Carousel page is not helpful because its not showing the previous/post image/video in same frame). If some has any answer for this that will be help full. I am able find IOS component(https://components.xamarin.com/view/Alliance.Carousel) but in android I don't have any clue. I want the effect like below or you can check the screenshot for help. Thanks in advance
1>2>3
Hi all) I've released new package for Xamarin.Forms (Something like Tinder's CardsView)
Maybe, someone will be interested in it
nuget.org/packages/CardsView/ -- nuget
github.com/AndreiMisiukevich/CardView -- source and samples
[ Cross posted from https://docs.microsoft.com/en-us/answers/questions/178266/any-advice-on-implementing-accessibility-for-xamar.html ]
When using VoiceOver on iOS to interact with Xamarin.Forms (4.8) ListViews, the user experience is pretty poor. For example, when ViewCells contain Labels that have the iOS UIAccessibilityTrait.Header trait specified, using the Rotor and swipe up/down to navigate between headers has issues. Even when the ListViewCachingStrategy is set to RetainElement, swiping will not navigate to a header that is not currently visible (i.e. it won't scroll into view, even if it has previously been viewed). Also, if the accessibility focus is currently outside the ListView, swiping up/down will not move the accessibility focus to an item with the Header trait inside the ListView.
Does anybody who has implemented accessibility in their Xamarin.Forms app(s) have any recommendations for how to add accessibility for ListViews? (not just VoiceOver, but other accessibility support too if possible).