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

how to get the coordinates where there is a control on the screen?

$
0
0

how could I get the coordinates of x, and a control image??


DateTime UTC+2

$
0
0

Hello,

I am working with a date and time, in the database everything looks good, but when I get the date and time, it always comes back 2 hours less, why is this?

Is it a problem with .net, xamarin, android?

Netflix video preview style in xamarin forms

$
0
0
Hi,

I am trying to achieve netflix video preview play style in xamarin forms since couple of days with no luck. I have tried with corousel view and progress bar at the top with scaling effect but that's not progressive. The problem is how to achieve progressive scaling of ProgressBar while swiping left or right. Could someone guide me how to do this. Thank you.
I have attached gif file for your reference.

BindingContext of DataTemplate

$
0
0

There is an example of Microsoft for using binding in DataTemplate:

     <CollectionView x:Name="ItemsCollectionView"
                ItemsSource="{Binding Items}">

            <CollectionView.ItemTemplate>
                <DataTemplate>
                    <StackLayout Padding="10">
                        <Label Text="{Binding Text}"                              
                                LineBreakMode="NoWrap" 
                                Style="{DynamicResource ListItemTextStyle}" 
                                FontSize="16" />
                ....

The binding context of this page is specified in the C# part (The page is ItemsPage)
public ItemsPage()
{
InitializeComponent();
BindingContext = viewModel = new ItemsViewModel();
}

and the ViewModel has all the specified Pathes in this example except "Text",
but in spite of this we see in the example the line:
<Label Text="{Binding Text}"

I understand from this that, the bindingContext of the dataTemplate is NOT the same binding context of the page,
but I don't see any place that a specific binding context is declared for the data template.

Where is the bindingContext of a dataTemplate declared?

ListView ItemTapped/ItemSelected is triggered when dragging the side panel of a MasterDetailPage

$
0
0

Hi,

we upgraded Xamarin Forms iOS from 4.2 to 4.7 and observed the following behaviour change in MasterDetailPage:

We have a MasterDetailPage. Master is a side panel with menu items and in Detail there is a NavigationPage with a list view.

In Forms 4.2, when the list view in Detail is visible, we could drag with the finger on the screen from left to right to drag the side panel into the screen. When we lift the finger up from the screen, the side panel will be presented fully. We can drag the side panel back again without triggering the itemTapped/itemSelected of the listview in the Detail Screen.

In Forms 4.7, when we drag with the finger on the list view from left to right and then lift the finger up from the screen, the itemTapped/itemSelected is triggered of the listview for the item where the finger was touched. That's bad. Everytime when I drag in the side panel, I activate an list item and you see the animation to the next page on right area of the screen.

This behaviour is not desired and I think this is a bug, or? Is there a workaround for it, with CustomRenderers?

On Android, this is not a problem. The side panel can be dragged in by dragging from the left edge to the right without triggering the itemselected of the list view. This works in Forms 4.2 and 4.7.

Best regards,
Mario

How to change the visibility of a Label using a Command (MVVM pattern)?

$
0
0

I have a label's "IsVisible" property set to "false" on my xaml page. And I want to change it to "true" when I press a button (ShowAnswerButton), using a Command (ShowAnswer)--I'm still figuring things out with the MVVM pattern! Thanks in advance!

(Also, please, can anybody tell me how to format these questions on the xamarin community forums. I keep having them like hard to follow, format-wise).

Here's what I have so far:

MainPage.xaml
<Label x:Name="AnswerLabel"
Text="{Binding answer}"
IsVisible="False"
FontSize="20"
BackgroundColor="Black"
TextColor="White"

            />

             <Button x:Name="ShowAnswerButton"
             Text="Show me the Answer"                 
             Command="{Binding ShowAnswer}"
           />

ViewModel
ShowAnswer = new Command(async () =>
{
Debug.WriteLine("Showing Answer");

        });

Which event will be raised after selecting Time in TimePicker?

$
0
0

Hi,

I want a event that is to be raised after selecting time from TimePicker, similar to DatePicker's DateSelected event. This event is raised after selecting Dateoption. But in TimePicker such type of event doesn't exist. As far as i checked, events like Focused, PropertyChanged all were raised before selecting Timeoption. But i need a event that is to be raised after selecting Time option, so that i can alert user if the selected Time were in past.

Cannot access a disposed object...

$
0
0

Hello everyone.

I'm having an issue where I am getting crashes at seemingly random intervals when navigating between pages, this seems to be exclusive to the Android build.

First a a bit of background info:

  • My app is using the latest version of Xamarin.Forms 4.7.
  • I have attempted to use XAML and Bindings where possible, implementing the ViewModelLocator pattern.
  • I have also disabled the FastRenderers because I utilize Grids to stack some views to get some of the desired effects.(Xamarin.Forms.Forms.SetFlags("UseLegacyRenderers")
  • I also make use of what we call UserControls (ContentViews with XAML) to create reusable, simplified controls.
  • Where possible values are assigned exclusively using Bindings.
  • Anywhere where I have used an Effect or similar, I have made sure to include null checks wherever it seems appropriate.
  • Navigation is handled using Navigation.PushAsync(page) for the most part.
  • The issue in question only seems to happen when pushing or popping from the navigation stack.
  • The app makes extensive use of CollectionViews
  • I've been running the app almost exclusively on a Samsung S10e physical device.

For the longest time, the crash only happened occasionally, and seemed infrequent enough that it could be comfortbly ignored, but now it seems to be happening almost every time I try to test the app. The actual trigger still seems random but it always happens when going between two pages, sometimes it triggers immediately, sometimes after a few tries.

It also, at first seemed to be exclusively linked to LabelRenderers, but has more recently also been linked to an ActivityIndicatorRenderer.

Here are a couple of the sorts of stack traces I'm getting:

[MonoDroid] System.ObjectDisposedException: Cannot access a disposed object.
[MonoDroid] Object name: 'Xamarin.Forms.Platform.Android.LabelRenderer'.
[MonoDroid]   at Java.Interop.JniPeerMembers.AssertSelf (Java.Interop.IJavaPeerable self) [0x00029] in <26521a5118b44c858c385715922b9d5d>:0 
[MonoDroid]   at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeNonvirtualObjectMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00000] in <26521a5118b44c858c385715922b9d5d>:0 
[MonoDroid]   at Android.Views.View.get_Context () [0x0000a] in <4ccdb3137d974856b786e1aeebbfbab6>:0 
[MonoDroid]   at Xamarin.Forms.Platform.Android.Platform.GetNativeSize (Xamarin.Forms.VisualElement view, System.Double widthConstraint, System.Double heightConstraint) [0x00019] in D:\a\1\s\Xamarin.Forms.Platform.Android\Platform.cs:1341 
[MonoDroid]   at Xamarin.Forms.Forms+AndroidPlatformServices.GetNativeSize (Xamarin.Forms.VisualElement view, System.Double widthConstraint, System.Double heightConstraint) [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.Android\Forms.cs:921 
[MonoDroid]   at Xamarin.Forms.VisualElement.OnSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00025] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:807 
[MonoDroid]   at Xamarin.Forms.VisualElement.OnMeasure (System.Double widthConstraint, System.Double heightConstraint) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:790 
[MonoDroid]   at Xamarin.Forms.VisualElement.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00053] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:666 
[MonoDroid]   at Xamarin.Forms.VisualElement.Measure (System.Double widthConstraint, System.Double heightConstraint, Xamarin.Forms.MeasureFlags flags) [0x00054] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:724 
[MonoDroid]   at Xamarin.Forms.Grid.MeasuredStarredColumns (System.Double widthConstraint, System.Double heightConstraint) [0x000b3] in D:\a\1\s\Xamarin.Forms.Core\GridCalc.cs:453 
[MonoDroid]   at Xamarin.Forms.Grid.MeasureAndContractStarredColumns (System.Double width, System.Double height, System.Double totalStarsWidth) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\GridCalc.cs:377 
[MonoDroid]   at Xamarin.Forms.Grid.MeasureGrid (System.Double width, System.Double height, System.Boolean requestSize) [0x0010e] in D:\a\1\s\Xamarin.Forms.Core\GridCalc.cs:511 
[MonoDroid]   at Xamarin.Forms.Grid.OnSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x0002a] in D:\a\1\s\Xamarin.Forms.Core\GridCalc.cs:60 
[MonoDroid]   at Xamarin.Forms.VisualElement.OnMeasure (System.Double widthConstraint, System.Double heightConstraint) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:790 
[MonoDroid]   at Xamarin.Forms.VisualElement.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00053] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:666 
[MonoDroid]   at Xamarin.Forms.Layout.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:132 
[MonoDroid]   at Xamarin.Forms.VisualElement.Measure (System.Double widthConstraint, System.Double heightConstraint, Xamarin.Forms.MeasureFlags flags) [0x00054] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:724 
[MonoDroid]   at Xamarin.Forms.Grid.CalculateAutoCells (System.Double width, System.Double height) [0x000e5] in D:\a\1\s\Xamarin.Forms.Core\GridCalc.cs:133 
[MonoDroid]   at Xamarin.Forms.Grid.MeasureGrid (System.Double width, System.Double height, System.Boolean requestSize) [0x0000c] in D:\a\1\s\Xamarin.Forms.Core\GridCalc.cs:485 
[MonoDroid]   at Xamarin.Forms.Grid.OnSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x0002a] in D:\a\1\s\Xamarin.Forms.Core\GridCalc.cs:60 
[MonoDroid]   at Xamarin.Forms.VisualElement.OnMeasure (System.Double widthConstraint, System.Double heightConstraint) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:790 
[MonoDroid]   at Xamarin.Forms.VisualElement.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00053] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:666 
[MonoDroid]   at Xamarin.Forms.Layout.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:132 
[MonoDroid]   at Xamarin.Forms.VisualElement.Measure (System.Double widthConstraint, System.Double heightConstraint, Xamarin.Forms.MeasureFlags flags) [0x00054] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:724 
[MonoDroid]   at Xamarin.Forms.TemplatedView.OnSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x0003c] in D:\a\1\s\Xamarin.Forms.Core\TemplatedView.cs:43 
[MonoDroid]   at Xamarin.Forms.VisualElement.OnMeasure (System.Double widthConstraint, System.Double heightConstraint) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:790 
[MonoDroid]   at Xamarin.Forms.VisualElement.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00053] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:666 
[MonoDroid]   at Xamarin.Forms.Layout.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:132 
[MonoDroid]   at Xamarin.Forms.VisualElement.Measure (System.Double widthConstraint, System.Double heightConstraint, Xamarin.Forms.MeasureFlags flags) [0x00054] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:724 
[MonoDroid]   at Xamarin.Forms.StackLayout.CalculateNaiveLayout (Xamarin.Forms.StackLayout+LayoutInformation layout, Xamarin.Forms.StackOrientation orientation, System.Double x, System.Double y, System.Double widthConstraint, System.Double heightConstraint) [0x000a8] in D:\a\1\s\Xamarin.Forms.Core\StackLayout.cs:163 
[MonoDroid]   at Xamarin.Forms.StackLayout.CalculateLayout (Xamarin.Forms.StackLayout+LayoutInformation layout, System.Double x, System.Double y, System.Double widthConstraint, System.Double heightConstraint, System.Boolean processExpanders) [0x00058] in D:\a\1\s\Xamarin.Forms.Core\StackLayout.cs:123 
[MonoDroid]   at Xamarin.Forms.StackLayout.LayoutChildren (System.Double x, System.Double y, System.Double width, System.Double height) [0x0004e] in D:\a\1\s\Xamarin.Forms.Core\StackLayout.cs:58 
[MonoDroid]   at Xamarin.Forms.Layout.UpdateChildrenLayout () [0x00158] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:266 
[MonoDroid]   at Xamarin.Forms.Layout.OnSizeAllocated (System.Double width, System.Double height) [0x0000f] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:224 
[MonoDroid]   at Xamarin.Forms.VisualElement.SizeAllocated (System.Double width, System.Double height) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:812 
[MonoDroid]   at Xamarin.Forms.Layout.ResolveLayoutChanges () [0x0005c] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:392 
[MonoDroid]   at Java.Lang.Thread+RunnableImplementor.Run () [0x00008] in <4ccdb3137d974856b786e1aeebbfbab6>:0 
[MonoDroid]   at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00009] in <4ccdb3137d974856b786e1aeebbfbab6>:0 
[MonoDroid]   at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.48(intptr,intptr)
[rocca.reps.rep] JNI RegisterNativeMethods: attempt to register 0 native methods for android.runtime.JavaProxyThrowable
[mono] Unhandled Exception:
[mono-rt]   at (wrapper native-to-managed) Android.Runtime.DynamicMethodNam07-14 10:20:20.035 E/mono    (10423): System.ObjectDisposedException: Cannot access a disposed object.
[mono] Object name: 'Xamarin.Forms.Platform.Android.LabelRenderer'.
[mono]   at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.48(intptr,intptr)
[mono]   at (wrapper native-to-managed) Android.Runtime.DynamicMethodNameCounter.48(intptr,intptr)
[mono-rt] [ERROR] FATAL UNHANDLED EXCEPTION: System.ObjectDisposedException: Cannot access a disposed object.
[mono-rt] Object name: 'Xamarin.Forms.Platform.Android.LabelRenderer'.
[mono-rt]   at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.48(intptr,intptr)
[mono-rt]   at (wrapper native-to-managed) Android.Runtime.DynamicMethodNameCounter.48(intptr,intptr)
[MonoDroid] UNHANDLED EXCEPTION:
[MonoDroid] System.ObjectDisposedException: Cannot access a disposed object.
[MonoDroid] Object name: 'Xamarin.Forms.Platform.Android.ActivityIndicatorRenderer'.
[MonoDroid]   at Java.Interop.JniPeerMembers.AssertSelf (Java.Interop.IJavaPeerable self) [0x00029] in <26521a5118b44c858c385715922b9d5d>:0 
[MonoDroid]   at Xamarin.Forms.Platform.Android.Platform.GetNativeSize (Xamarin.Forms.VisualElement view, System.Double widthConstraint, System.Double heightConstraint) [0x00019] in D:\a\1\s\Xamarin.Forms.Pl07-13 17:37:40.155 I/MonoDroid(14402):   at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeNonvirtualObjectMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00000] in <26521a5118b44c858c385715922b9d5d>:0 
[MonoDroid]   at Android.Views.View.get_Context () [0x0000a] in <4ccdb3137d974856b786e1aeebbfbab6>:0 
[MonoDroid]   at Xamarin.Forms.VisualElement.Measure (System.atform.Android\Platform.cs:1341 
[MonoDroid]   at Xamarin.Forms.Forms+AndroidPlatformServices.GetNativeSize (Xamarin.Forms.VisualElement view, System.Double widthConstraint, System.Double heightConstraint) [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.Android\Forms.cs:921 
[MonoDroid]   at Xamarin.Forms.VisualElement.OnSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00025] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:807 
[MonoDroid]   at Xamarin.Forms.VisualElement.OnMeasure (System.Double widthConstraint, System.Double heightConstraint) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:790 
[MonoDroid]   at Xamarin.Forms.VisualElement.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00053] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:666 
[MonoDroid]   at Xamarin.Forms.TemplatedView.OnSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x0003c] in D:\a\1\s\Xamarin.Forms.Core\TemplatedView.cs:43 
[MonoDroid]   at Xamarin.Forms.VisualElement.OnMeasure (System.Double widthConstraint, System.Double heightConstraint) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:790 
[MonoDroid]   at Xamarin.Forms.VisualElement.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00053] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:666 
[MonoDroid]   at Xamarin.Forms.StackLayout.LayoutChildren (System.Double x, System.Double y, System.Double width, Sy07-13 17:37:40.155 I/MonoDroid(14402):   at Xamarin.Forms.Layout.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:132 
[MonoDroid]   at Xamarin.Forms.StackLayout.CalculateNaiveLayout (Xamarin.Forms.StackLayout+LayoutInformation layout, Xamarin.Forms.StackOrientation orientation, System.Double x, System.Double y, System.Double widthConstraint, System.Double heightConstraint) [0x000a8] in D:\a\1\s\Xamarin.Forms.Core\StackLayout.cs:163 
[MonoDroid]   at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00009] in 07-13 17:37:40.155 I/MonoDroid(14402):   at Xamarin.Forms.StackLayout.CalculateLayout (Xamarin.Forms.StackLayout+LayoutInformation layout, System.Double x, System.Double y, System.Double widthConstraint, System.Double heightConstraint, System.Boolean processExpanders) [0x00058] in D:\a\1\s\Xamarin.Forms.Core\StackLayout.cs:123 
[MonoDroid]   at Xamarin.Forms.Layout.UpdateChildrenLayout () [0x00158] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:266 
[MonoDroid]   at Xamarin.Forms.Layout.OnSizeAllocated (System.Double width, System.Double height) [0x0000f] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:224 
[MonoDroid]   at Xamarin.Forms.VisualElement.SizeAllocated (System.Double width, System.Double height) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:812 
[MonoDroid]   at Xamarin.Forms.Layout.ResolveLayoutChanges () [0x0005c] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:392 
[MonoDroid]   at Java.Lang.Thread+RunnableImplementor.Run () [0x00008] in <4ccdb3137d974856b786e1aeebbfbab6>:0 
[MonoDroid]   at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00009] in <4ccdb3137d974856b786e1aeebbfbab6>:0 
[MonoDroid]   at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.48(intptr,intptr)
[rocca.reps.rep] JNI RegisterNativeMethods: attempt to register 0 native methods for android.runtime.JavaProxyThrowable
[Mono] DllImport searching in: '__Internal' ('(null)').
[Mono] Searching for 'java_interop_jnienv_throw'.
[Mono] Probing 'java_interop_jnienv_throw'.
[Mono] Found as 'java_interop_jnienv_throw'.
[mono] 
[mono] Unhandled Exception:
[mono] System.ObjectDisposedException: Cannot access a disposed object.
[mono] Object name: 'Xamarin.Forms.Platform.Android.ActivityIndicatorRenderer'.
[mono]   at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.48(intptr,intptr)
[mono]   at (wrapper native-to-managed) Android.Runtime.DynamicMethodNameCounter.48(intptr,intptr)
[mono-rt]   at (wrapper native-to-managed) Android.07-13 17:37:42.541 E/mono-rt (14402): [ERROR] FATAL UNHANDLED EXCEPTION: System.ObjectDisposedException: Cannot access a disposed object.
[mono-rt] Object name: 'Xamarin.Forms.Platform.Android.ActivityIndicatorRenderer'.
[mono-rt]   at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.48(intptr,intptr)
[mali_winsys] delete_surface() [1080x2280] return

Any help would be greatly appreciated!

Thanks :smile:


How to implement video calling using twilio in using xamarin forms for both ios and android

$
0
0

I am struct to implement video calling future into app please suggest me possible ways

how to delete an item in a ListView using SwipeView

$
0
0

Hi, this seems to be easy but not for everyone.

I can delete the item using Command (the right way for MVVM) or using code behind.

First, if I use code behind it is easy to display an alert message but I don't know how to get the item:
XAML:

                                   <SwipeItems Mode="Execute">
                                        <SwipeItem Text="{i18n:Translate buttonDelete}"
                                                IconImageSource="delete.png"
                                                BackgroundColor="{StaticResource TextRedNightColor}"
                                                Invoked="OnDelete"/>
                                    </SwipeItems>

code behind:

        async void OnDelete(object sender, EventArgs args)
        {
                bool answer = await DisplayAlert(
                rm.GetString("warning"),
                rm.GetString("messageDeleteSight"),
                rm.GetString("deleteAnyway"),
                rm.GetString("cancel"));
                if (answer)
                {
                    //await AlmicantaratXF.Views.App.PositionsSightsDB.DeleteSightAsync(***some thing to write here to get the item***);
                }
            }
        }

When I tap on an item I get the item easily:

        async void OnSightSelected(object sender, SelectedItemChangedEventArgs e)
        {
            (sender as ListView).SelectedItem = null;
            if (e.SelectedItem != null)
            {
                await Navigation.PushAsync(new SightPage(e.SelectedItem as Sight));
            }
        }

But when I swipe the item I don't have any SelectedItemChangedEventArgs e, so I don't know how to get the item.

Second, I did delete the item using Command, but there is no more alert message and I don't know how to refresh the ListView so that the item does not appear anymore.
The ListView is populated during the OnAppearing (does that help?):

        protected override async void OnAppearing()
        {
            base.OnAppearing();
            Model.Position currentPosition = BindingContext as Model.Position;
            listView.ItemsSource = await AlmicantaratXF.Views.App.PositionsSightsDB.GetSightsAsync(currentPosition);
        }
  1. how to get the item in the code behind after a swipe?
  2. how to refresh the listview when the item is deleted?

Access to the Path is Denied with FileStream

$
0
0

Hi,

I am smashing my head with the below error whenever I tried to access the below Path.

Android Apk:

I am trying to upload an excel sheet from user to the android storage and reads it to load it into SQLDB in Azure.

I am getting a below error when I am trying to access the below paths.

Error : System.UnauthorizedAccessException: 'Access to the path '/

CodeBehind:

var folderPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal); ---- "/storage/emulated/0/Android/data/com.companyname.sevendashboard/files"
var folderPath = DependencyService.Get().GetExternalStorage();
"/data/user/0/com.companyname.sevendashboard/files"
varfolderPath = Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryDownloads).ToString();
"/storage/emulated/0/Download"

var file = Path.Combine(pat, "abc.xls");
FileStream stream = File.Open(file, FileMode.Open, FileAccess.Read);

Below is my Manifest:





Main Activity:

    public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Android.Content.PM.Permission[] grantResults)
    {
        Xamarin.Essentials.Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults);

        base.OnRequestPermissionsResult(requestCode, permissions, grantResults);


    }

Pass Page Name in codebehind

$
0
0

Hi,

I am trying to open the Page About in below example from the codebehind, Angels in my Assembly name and Default namespace:

private void ListViewHomePage_ItemTapped(object sender, Syncfusion.ListView.XForms.ItemTappedEventArgs e)
{
    INavigation navService;

    navService = App.Current.MainPage.Navigation;

    var targetPageType = Type.GetType("Angels.About");
    var targetPageInstance = (Page)Activator.CreateInstance(targetPageType, "About");

    App.Current.MainPage.Navigation.PushModalAsync(new NavigationPage(targetPageInstance));
}

but I am getting this error:

System.MissingMethodException: 'Constructor on type 'Angels.About' not found.'

Kindly help..

Thanks,
Jassim

SwipeView Background around round corners white only

$
0
0

Hi,
I set round corners to the SwipeView. Unfortunately, the color around the corners are white, that is ugly.
I would like to set the color around the corners to "{StaticResource AppBackgroundColor}"
How to set that?

This is my xaml code and below a sreenshot:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="AlmicantaratXF.Views.CelestialPositionPage"
             xmlns:i18n="clr-namespace:AlmicantaratXF.Views;assembly=AlmicantaratXF"
             xmlns:viewModels="clr-namespace:AlmicantaratXF.ViewModels;assembly=AlmicantaratXF"
             Title="{i18n:Translate titleCelestialPosition}">
    <ContentPage.Padding>
        <OnPlatform x:TypeArguments="Thickness">
            <On Platform="iOS" Value="10, 20, 10, 5" />
            <On Platform="Android, UWP" Value="10, 0, 10, 5" />
        </OnPlatform>
    </ContentPage.Padding>
    <!--    <ContentPage.BindingContext>
        <viewModels:CelestialPositionViewModel/>
    </ContentPage.BindingContext> -->
    <ContentPage.Resources>
        <ResourceDictionary>
            <Style TargetType="Entry" >
                <Setter Property="Keyboard" Value="Numeric" />
            </Style>
        </ResourceDictionary>
    </ContentPage.Resources>
    <ContentPage.ToolbarItems>
        <ToolbarItem Text="{i18n:Translate buttonDelete}" Clicked="OnDelete" />
    </ContentPage.ToolbarItems>
    <ContentPage.Content>
        <StackLayout  Orientation="Vertical">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="2*" />
                    <ColumnDefinition Width="3*" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <Label Text="{i18n:Translate labelDateTime}" Grid.Row="0" Grid.Column="0" />
                <Label Text="{Binding StrDateTime}"  Grid.Row="0" Grid.Column="1"
                       TextColor="{StaticResource LabelInfoTextColor}"/>

                <Label Text="{i18n:Translate labelPositionMethod}" Grid.Row="1" Grid.Column="0" />
                <Label Text="{Binding StrMethod}"  Grid.Row="1" Grid.Column="1"
                       TextColor="{StaticResource LabelInfoTextColor}"/>
            </Grid>
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <Label Text="{i18n:Translate lat}" Grid.Row="0" Grid.Column="0" />
                <Label Text="{Binding StrLat}"  Grid.Row="1" Grid.Column="0"
                       TextColor="{StaticResource LabelInfoTextColor}"/>

                <Label Text="{i18n:Translate lon}" Grid.Row="0" Grid.Column="1" />
                <Label Text="{Binding StrLon}"  Grid.Row="1" Grid.Column="1"
                       TextColor="{StaticResource LabelInfoTextColor}"/>
            </Grid>            
            <Button Text="{i18n:Translate buttonNewSight}"
                    Clicked="OnNewSightClicked">
                <!--HorizontalOptions="StartAndExpand" -->
            </Button>
            <ListView x:Name="listView"
                      SeparatorVisibility="Default"
                      HasUnevenRows = "true"
                      ItemSelected="OnSightSelected"
                      RowHeight="40"
                      BackgroundColor="{StaticResource AppBackgroundColor}">
                <ListView.Header>

                </ListView.Header>
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <ViewCell>

                            <SwipeView>

                                <SwipeView.LeftItems>
                                    <SwipeItems Mode="Execute">
                                        <SwipeItem Text="{i18n:Translate buttonDelete}"
                                                IconImageSource="delete.png"
                                                BackgroundColor="{StaticResource TextRedNightColor}"
                                                Invoked="OnDeleteSight"/>
                                    </SwipeItems>
                                </SwipeView.LeftItems>
                                <Frame CornerRadius="16" Margin="0" BackgroundColor="{StaticResource CellDefaultColor}"
                                       HasShadow="False" BorderColor="{StaticResource CellDefaultColor}" >
                                <StackLayout Orientation="Vertical"
                                            Margin="1"
                                            Padding="0"
                                             BackgroundColor="{StaticResource CellDefaultColor}">
                                    <Label Text="{Binding StrDateTime}"
                                        TextColor="{StaticResource LabelInfoTextColor}"
                                           BackgroundColor="{StaticResource CellDefaultColor}"/>
                                    <StackLayout Orientation="Horizontal"
                                                Margin ="0"
                                                Padding="0"
                                                HorizontalOptions="FillAndExpand" >
                                        <Label Text="{Binding StrBody}"
                                            TextColor="{StaticResource LabelInfoTextColor}"
                                               BackgroundColor="{StaticResource CellDefaultColor}"
                                            WidthRequest="140"
                                            Margin="0"/>
                                        <Label Text="{Binding StrAltitude}"
                                            TextColor="{StaticResource LabelInfoTextColor}"
                                               BackgroundColor="{StaticResource CellDefaultColor}"
                                            WidthRequest="150" />
                                    </StackLayout>
                                </StackLayout>
                            </Frame>
                            </SwipeView>


                        </ViewCell>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>
        </StackLayout>
    </ContentPage.Content>
</ContentPage>

Issue/Problem in using "checkmark" for iOS using ViewCellRenderer

$
0
0

Hi,

In my Xamarin forms app for iOS I want to have a native "checkmark" for selecting one item from list of items (ViewCell in table). So I have created "BaseViewCell" derived from "ViewCell" and written a Renderer for the same. But the issue I am facing is that when I toggle between "select" and "unselect" item it at one point selects (multiple checkmark) more than one item from the list. So, I see more than one checkmark for items instead of one. It should only select one item and not more than one. Can you help me how do I solve this problem.

I have attached the code file for reference. Kindly rename attached file extension to ".cs".

Help is really appreciated.

Xamarin forms version: "4.3.0.991221".

Thanks and Regards.

How do I show first Grid row first when application load.

$
0
0

It appears that my Grid layout the second row is displaying first.
Her is my code.

When the application loads Grid.Row="2" which is the middle part of the page show first.
I have to scroll down to see the carousel witch Grid.Row="1"

<ScrollView HorizontalOptions="Center"> <Grid x:Name="page" Padding="0,0"> <Grid.RowDefinitions> <RowDefinition Height="600" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> </Grid.RowDefinitions> <StackLayout Grid.Row="0"> <CarouselView x:Name="carousel" Scrolled="Handle_Scrolled" ItemsSource="{Binding Items}" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand"> <CarouselView.Behaviors> <behaviors:FrontBannerViewParallaxBehavior ParallaxOffset="100"/> </CarouselView.Behaviors> <CarouselView.ItemTemplate> <DataTemplate> <Grid Padding="18,24,18,64"> <custom:PancakeView CornerRadius="24" BackgroundColor="#FFFFFF"> <StackLayout VerticalOptions="Fill" HorizontalOptions="Fill"> <custom:PancakeView VerticalOptions="FillAndExpand" HeightRequest="200" CornerRadius="10" BackgroundGradientStartColor="{Binding StartColor}" BackgroundGradientEndColor="{Binding EndColor}"> <Grid> <StackLayout> <StackLayout Orientation="Horizontal"> <Label Text="{Binding Title}" FontFamily="{StaticResource font_extrabold}" HorizontalOptions="Center" TextColor="#60229a" VerticalOptions="End" Margin="14,0,0,0" FontSize="36" FontAttributes="Bold" LineBreakMode="NoWrap" /> </StackLayout> <Label FontFamily="{StaticResource font_regular}" Text="{Binding Details}" TextColor="#60229a" Margin="14,8,24,24" FontSize="22" LineBreakMode="WordWrap" /> </StackLayout> </Grid> </custom:PancakeView> </StackLayout> </custom:PancakeView> <Image Source="{Binding ImageSrc}" WidthRequest="{Binding Width}" VerticalOptions="EndAndExpand" HorizontalOptions="EndAndExpand" Margin="0,0,15,0" /> </Grid> </DataTemplate> </CarouselView.ItemTemplate> </CarouselView> </StackLayout>

       ` <StackLayout Grid.Row="1">
            <StackLayout Orientation="Horizontal">
                <Label Text="Listen to Apostle Johnson's" FontFamily="{StaticResource font_extrabold}" HorizontalOptions="Center" TextColor="#FFFFFF" VerticalOptions="End" Margin="14,0,0,0" FontSize="36" FontAttributes="Bold" LineBreakMode="NoWrap" />
            </StackLayout>
            <Label FontFamily="{StaticResource font_regular}"  Text="Detox Transformation." TextColor="#FFFFFF" Margin="14,8,24,24" FontSize="22" LineBreakMode="WordWrap" />

            <StackLayout Orientation="Horizontal">
                <Label FontFamily="{StaticResource font_regular}" Text="Apostle Johnson gives a riveting short bio of his testimony of traveling a road of living a life of descriptive chaos.  Hey just click on the video and hear it from him." TextColor="#FFFFFF" Margin="14,8,24,24" FontSize="22" LineBreakMode="WordWrap" />
            </StackLayout>
            <StackLayout Orientation="Horizontal">
                <ovideo:VideoPlayer x:Name="vmo" Source="http://iowegodministry.org/wp-content/uploads/2020/06/y2mate.com-FROM-GANGSTA-TO-GOD_JeR29HVa7HE_360p.mp4" WidthRequest="250" />
            </StackLayout>
        </StackLayout> 
        <StackLayout Grid.Row="2">
            <StackLayout Orientation="Horizontal">
                <Label Text="Chance Program" FontFamily="{StaticResource font_extrabold}" HorizontalOptions="Center" TextColor="#FFFFFF" VerticalOptions="End" Margin="14,0,0,0" FontSize="36" FontAttributes="Bold" LineBreakMode="NoWrap" />
            </StackLayout>
            <Label FontFamily="{StaticResource font_regular}"  Text="The mission of C.H.A.N.C.E. is to help people succeed in the workforce by providing training and mentorship.  One of the goals is to help those who've been in the prison system become successful members of society after they get out.  The program will provide classes on a variety of spiritual-based educational curriculum, teach job interview skills, and help with strengthening family relationships and bonds." TextColor="#FFFFFF" Margin="14,8,24,24" FontSize="22" LineBreakMode="WordWrap" />
            <Button BackgroundColor="#FFFFFF" 
                    FontFamily="{StaticResource font_bold}" 
                    Padding="20,0" CornerRadius="20" 
                    TextColor="{Binding BackgroundColor}" 
                    FontSize="12" BorderColor="{Binding BackgroundColor}" 
                    BorderWidth="2" HeightRequest="40" 
                    Text="Read More About the Program" HorizontalOptions="Center" Clicked="OnButtonClicked"
                    />
        </StackLayout>
    </Grid>
</ScrollView>`

In Release Mode i am geetin error XA2006

$
0
0

Hello fellows, since 5 days , i am trying to figure out the how to solve these problem, tried to update libraries , nuget package, etc. it just happens in RELEASE mode, in Debug mode, the APP runs Ok. the main problem here is 1- the error XA2006 2- the size of the APK once it is generated., the only workaround i found is to disable the assembly's linking in AndroidProject Properties, wich is not the more fancy solution and optimistic neither.

if anyone can give any clue about wich road to take, it will be fully appreciated.
I am using VisualStudio 2019.

error XA2006: No se pudo resolver la referencia a "Android.Support.V7.App.NotificationCompat/MediaStyle" (definida en el ensamblado "Plugin.MediaManager, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null") con el ámbito "Xamarin.Android.Support.v7.AppCompat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"

Xamarin forms: Issue with epubreader.cross

$
0
0

I am using epubreader.cross NuGet package for parsing .epub files.

My Code:

string fileName = "SampleEPUB.epub";
var assembly = typeof(MainPage).GetTypeInfo().Assembly;
Stream stream = assembly.GetManifestResourceStream($"{assembly.GetName().Name}.{fileName}");
EpubBook epubBook = EpubReader.ReadBook(stream);

For some .epb files I am getting below exceptions:

System.AggregateException: 'One or more errors occurred. (Incorrect EPUB navigation page target: normal is incorrect value for page target type.)'

System.AggregateException: 'One or more errors occurred. (Incorrect EPUB spine: TOC is missing)'

All my .epub files are able to view using Adobe Digital Editions 4.5.11. So what will be the reason behind this issue?

I have added a sample project here having .epub files for the reference.

How i can resolve this issue?? i got it after my Post Method Is Call

$
0
0

result = {StatusCode: 400, ReasonPhrase: 'Bad Request', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
Date: Fri, 17 Jul 2020 12:50:44 GMT
Server: Microsoft-IIS/10.0
Transfer-Encoding: chunked
X-Android-Received-Millis: 1594990244404
...

Apple Signin Url scheme Handling Problem

$
0
0

Im using applesignin from github Xamarin Samples (SigningWithApple)

I am having issue like xamarin app freezes after login with apple. I guess scheme not handling. Could you give me an idea. it occurs on both ios and android.

thanks.

Fill Picker from table

$
0
0

Greetings everyone
i have no idea how to fill value of picker from table i have this table
i'm using (c#markup)

class TypeRequstTB
    {
        public int IdTypeReuqst { get; set; }
        public string NameTypeRequest { get; set; }
    }

and i want get value from this field (IdTypeReuqst) and i want display title from this field (NameTypeRequest)
so i did this code but still not get me as i want

_TypeRequst = new Picker();
            _TypeRequst.ItemsSource = db.Table<TypeRequstTB>().OrderBy(x => x.NameTypeRequest).ToList();
            _TypeRequst.Title = "NameTypeRequest";
            _TypeRequst.SelectedItem = "IdTypeReuqst";
            stackLayout.Children.Add(_TypeRequst);

how can i get value and title from that table?!!

Viewing all 79144 articles
Browse latest View live


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