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

blank MasterDetailPage or controled template with databinding

$
0
0

I wanted to render my navigation in App.xaml is because I have controled template there. I have a template for Navigation and other stuff and then I just render different pages inside .

It seems like I am not able to databind into App.xaml controled template. I wanted to transfer my controled template to the normal content page but thats not possible as It has to be in Application class.

So I decided to go with MasterDetailPage. Problem with this is that IT has this garbage functionality like drawer manu and so on. I dont want to. I cant have that in my app. Is there a possibility to completelety destroy this functionality and just create masterdetailpage from scratch(like controled template) without using all of that stuff that comes with it ?

This is exactly how my app has to look like.


How can we add support for HTTP/2 with HttpClient?

$
0
0

Hi All.
I have tried to set request.Version=new Version("2.0") in SendAsync method but got an error
"Only HTTP/1.0 and HTTP/1.1 version requests are currently supported. "
I am using native handlers on both platforms.

how to share datatemplate as resourcedictionary between pages?

$
0
0

I have listview with a swipetemplate as below

    <ResourceDictionary
      <DataTemplate   x:Key="SwipeTemplate">

                <ffimageloadingsvg:SvgCachedImage Grid.Row="0"
                               Style="{StaticResource ImgSwapStyle}" 
                               Source="delete.svg" >
                    <ffimageloadingsvg:SvgCachedImage.GestureRecognizers>
                        <TapGestureRecognizer
                            Command="{Binding Path=BindingContext.OnDeleteClick, Source={x:Reference Name=list}}"
                            CommandParameter="{Binding .}"                       
                        />
                    </ffimageloadingsvg:SvgCachedImage.GestureRecognizers>
                </ffimageloadingsvg:SvgCachedImage>

        </DataTemplate>
</ResourceDictionary>

      <sfListView:SfListView x:Name="list"  BackgroundColor="White" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand" 
             ...
                                           SelectedItem="{Binding SelectedItem, Mode=TwoWay}"  
                                           LeftSwipeTemplate="{StaticResource SwipeTemplate}">

Basically if SwipeTemplate is defined in the contentpage's resourcedictionary it works but i want to use it shared for all my pages where i have listview, therefore i need to have it in a merged dictionary. So once i defined resourcedictionary globally, it wont work. because of Source={x:Reference Name=list}.
Although all my listview's are called list, it doesnt work. So how I reference and bind it in a global resourcedictionary?

Crash on Android

$
0
0

Hi,
Below is the crash log, does anyone know why its crashing in android.

AvailabilityViewModel+d__45.MoveNext ()
System.NullReferenceException: Object reference not set to an instance of an object

This the function CellTapped :

private async void CellTapped(object sender, CalendarCell e)
{
this.IsBusy = true;

        if (e is CalendarDayCell dayCell)
        {
            if(dayCell != null)
            {
                DateTime date = dayCell.Date;
                List<IAppointment> availability = (sender as RadCalendar)?.AppointmentsSource?.Where(a => a.StartDate.Date == date).ToList();

                if (availability == null || !availability.Any())
                {
                    if (date.Date < DateTime.Now.Date)
                    {
                        await this.DialogsService.ShowAlertAsync("Non è possibile inserire disponibilità per date passate.", "Informazione", "OK");
                    }
                    else
                    {
                        /* ANCORA NON SONO STATE INSERITE DISPONIBILITA' PER LA DATA SELEZIONATA 
                         * IMPOSTAZIONE RAPIDA: "DISPONIBILITA' DI TUTTA LA GIORNATA" */
                        DateTime startDate = new DateTime(date.Year, date.Month, date.Day, 0, 0, 0);
                        DateTime endDate = new DateTime(date.Year, date.Month, date.Day, 23, 59, 59);

                        Shift newShift = new Shift()
                        {
                            ID = 0,
                            IsAllDay = true,
                            StartDate = startDate,
                            EndDate = endDate,
                            Detail = "New",
                            Title = "New",
                            Slot = 1,
                            ToSend = false
                        };

                        // LO AGGIUNGO ALLA LISTA PER POTERLO VISUALIZZARE NEL CALENDARIO
                        this.AvailabilityList.Add(newShift);

                        // LO SALVO IN LOCALE
                        await this.TaleteService.SaveShiftLocal(newShift)
                            .ContinueWith(
                                async a =>
                                {
                                    await this.HandleShiftsPresentationAsync();
                                },
                                TaskScheduler.FromCurrentSynchronizationContext()).ConfigureAwait(false);
                    }
                }
                else
            {
                // APRO IN MODIFICA
                await PopupNavigation.Instance.PushAsync(new AvailabilityPopUpView());

                // DEVO VERIFICARE SE AVEVO ASSEGNATO PRECEDENTEMENTE LO SLOT
                if(availability.Count > 1)
                {
                    if((availability.First() as Shift).ID == 0 && (availability.First() as Shift).Active)
                    {
                        if ((availability.First() as Shift).Slot == 1)
                        {
                            Shift1 = (Shift)availability.First();
                            Shift2 = (Shift)availability.Last();
                        }
                        else
                        {
                            Shift2 = (Shift)availability.First();
                            Shift1 = (Shift)availability.Last();
                        }
                    }
                    else
                    {
                        Shift1 = (Shift)availability.First();
                        Shift2 = (Shift)availability.Last();
                    }

                }
                else
                {
                    this.Shift1 = (Shift)availability.First();
                    //if (this.Shift1.Active && this.Shift1.ID == 0)
                    //{
                    //    this.Shift1.Slot = 1;
                    //}

                    this.Shift2 = null;
                }




                // ALMENO UNO SHIFT DEVE ESISTE
                //this.Shift1 = (Shift)availability.First();
                //if (this.Shift1.Active && this.Shift1.ID == 0)
                //{
                //    this.Shift1.Slot = 1;
                //}

                //if (availability.Count > 1)
                //{
                //    this.Shift2 = (Shift)availability.Last();
                //    if (this.Shift2.Active && this.Shift2.ID == 0)
                //    {
                //        this.Shift2.Slot = 2;
                //    }
                //}
                //else
                //{
                //    this.Shift2 = null;
                //}

                MessagingCenter.Send(new AvailabilityModifyMessage { Date = date, Shift1 = this.Shift1, Shift2 = this.Shift2 }, "AvailabilityShifts");
            }
            }
        }

        this.IsBusy = false;
    }

How to display 3 images in a row

$
0
0

i want to display saved in database as 3 images in a row like wise , display all images saved in database.
for example just like this

and when i click an image i want to go to another page and need its details in next page. How can i do this?

How to display my menu of my tabbedpage all over

$
0
0

Hi xamarin forum,

is it possible to display my menu of my tabbedpage all over my app? and the look would be like also a Tabbedpage

How to create layout List/GridView in CarouselView?

Xamarin.Forms parent BindingContext in DataTemplate in the XAML

$
0
0

After few hours of research, I finally found a solution to my problem. I saw that other people had the same problem : I have a listview with a custom viewcell as datatemplate, the contentpage viewmodel has a shared command "RemoveItem" and I want to invoke it from my custom viewcell.
The original error was : "Xamarin.Forms.Xaml.XamlParseException: No Property of name ElementName found".

In the XAML of my contentpage ("cells" reference the namespace with my customs viewcells):

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Name="cart"/>
<DataTemplate>
    <cells:CartViewCell ParentContext="{Binding BindingContext, Source={x:Reference cart}}"/>
</DataTemplate>

In the class of my custom viewcell:

public partial class CartViewCell : ViewCell
    {
        public CartViewCell()
        {
            InitializeComponent();
        }

        public static readonly BindableProperty ParentContextProperty =
            BindableProperty.Create("ParentContext", typeof(object), typeof(CartViewCell), null, propertyChanged: OnParentContextPropertyChanged);

        public object ParentContext
        {
            get { return GetValue(ParentContextProperty); }
            set { SetValue(ParentContextProperty, value); }
        }

        private static void OnParentContextPropertyChanged(BindableObject bindable, object oldValue, object newValue)
        {
            if (newValue != oldValue && newValue != null)
            {
                (bindable as CartViewCell).ParentContext = newValue;
            }
        }
    }

And in the XAML of my customviewcell:

<ViewCell xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Name="cartCell"><Image.GestureRecognizers>
    <TapGestureRecognizer Command="{Binding ParentContext.RemoveItem, Source={x:Reference cartCell}}" CommandParameter="{Binding .}"/>
</Image.GestureRecognizers>

Sorry if I made some mistakes, french guy :blush:
If you have a better solution I am interested because it's look like a hack for me.


App is crashing after deploying in xamarin.forms Android but works fine in ios

$
0
0

Actually we done chat application in xamarin.forms .In that when we load multiple messages or sometimes while sending message or sometimes scrolling list items app is crashing unknowingly and getting below error message in output window.In android only app is crashing but in ios it is working fine
Can anyone Please help me?

06-20 17:22:42.441 F/art ( 8220): art/runtime/runtime.cc:465] JNI DETECTED ERROR IN APPLICATION: use of deleted global reference 0x202b66
06-20 17:22:42.441 F/art ( 8220): art/runtime/runtime.cc:465] "Thread-25" prio=10 tid=35 Runnable
06-20 17:22:42.441 F/art ( 8220): art/runtime/runtime.cc:465] | group="main" sCount=0 dsCount=0 obj=0x2ac09280 self=0x818a2a00
06-20 17:22:42.441 F/art ( 8220): art/runtime/runtime.cc:465] | sysTid=8325 nice=-10 cgrp=default sched=0/0 handle=0x806fd920
06-20 17:22:42.441 F/art ( 8220): art/runtime/runtime.cc:465] | state=R schedstat=( 1034125416 3785778731 5300 ) utm=85 stm=18 core=0 HZ=100
06-20 17:22:42.441 F/art ( 8220): art/runtime/runtime.cc:465] | stack=0x805ff000-0x80601000 stackSize=1022KB
06-20 17:22:42.441 F/art ( 8220): art/runtime/runtime.cc:465] | held mutexes= "mutator lock"(shared held)
06-20 17:22:42.441 F/art ( 8220): art/runtime/runtime.cc:465] (no managed stack frames)
06-20 17:22:42.441 F/art ( 8220): art/runtime/runtime.cc:465]
06-20 17:22:42.441 F/art ( 8220): art/runtime/runtime.cc:465]
06-20 17:22:42.442 F/libc ( 8220): Fatal signal 6 (SIGABRT), code -6 in tid 8325 (Thread Pool Wor)

Running my xamarin forms project from the command line?

$
0
0

How can I run my xamarin forms project on iOS simulator via command line (terminal on mac)?

I have seen usage of mono, msbuild and dotnet.

Xamarin.Forms *needs* a hot reload system

$
0
0

Flutter is winning the hearts and minds of developers. I can see there is already jobs opening asking for flutter knowledge. Everywhere I read about flutter, people praise one functionality: "hot reload". I tested it and it is really nice. The thing is, flutter does not need it as much as XF. On flutter, things look the same on both devices so you do not spend so much time doing micro adjustments to the UI as on XF. The thing, I think, is that people learning need to see the changes they make to understand and learn. A person that does not know xaml will have a hard time even doing basic things look half decent. An experienced developer will have a hard time making things look exactly how he wants. It is possible but takes a lot of time.

I know about LiveXAML (http://www.livexaml.com/), I use it and it mostly works but it is not free. I know about XAMLator (https://github.com/ylatuya/XAMLator) and HotReload (https://github.com/AndreiMisiukevich/HotReload) but one only works on mac and the other I could not make work on android emulators. So, if this amazing developers are doing it, it is possible.

I think the most important thing for this feature is to be able to edit xaml on VS and see the change on emulators (android and iOS). It would be amazing if it could reload code changes too but only xaml will be a good start. It would be nice too if it could work without Visual Studio too, so I can edit .xaml files on VSCode and see the changes on my running app. This would make things so much better for experienced developers and for newcomers.

So my question is: when will Xamarin.Forms have an official hot reload system?

[iOS] Is anyone else having Autofac Constructor Resolving issues after the latest Xamarin update?

$
0
0

Yesterday, after updating to the latest version of Xamarin (both VS and XS), now my app won't start on iOS (still fine on Android) with the following exception. (did not fail prior to the update)

Autofac.Core.DependencyResolutionException: No constructors on type 'FutureState.AppCore.Migrations.Migration001' can be found with the constructor finder 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder'.

I even went ahead and changed the constructor to utilize service location

public Migration001(){
    _someService = App.Container.Resolve<SomeService>();
}

and got the exact same crash (iOS only).

Is anyone else seeing this? Is it an underlying issue in the latest release of Xamarin, or does Autofac need a tweak?

2014-09-04 10:04:42.288 FutureStateBreathingRoomiOS[2042:60b] Unhandled managed exception: No constructors on type 'FutureState.AppCore.Migrations.Migration001' can be found with the constructor finder 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder'. (Autofac.Core.DependencyResolutionException)
  at Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance (IComponentContext context, IEnumerable`1 parameters) [0x00000] in <filename unknown>:0 
  at Autofac.Core.Resolving.InstanceLookup.Activate (IEnumerable`1 parameters) [0x00000] in <filename unknown>:0 
  at Autofac.Core.Resolving.InstanceLookup.Execute () [0x00000] in <filename unknown>:0 
  at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance (ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters) [0x00000] in <filename unknown>:0 
  at Autofac.Core.Resolving.InstanceLookup.ResolveComponent (IComponentRegistration registration, IEnumerable`1 parameters) [0x00000] in
 <filename unknown>:0 
  at Autofac.Features.Collections.CollectionRegistrationSource+<>c__DisplayClass4+<>c__DisplayClass6.<RegistrationsFor>b__1 (IComponentRegistration cr) [0x00000] in <filename unknown>:0 
  at System.Linq.Enumerable+<CreateSelectIterator>c__Iterator10`2[Autofac.Core.IComponentRegistration,System.Object].MoveNext () [0x00000] in <filename unknown>:0 
  at System.Linq.Enumerable.ToArray[Object] (IEnumerable`1 source) [0x00000] in <filename unknown>:0 
  at Autofac.Features.Collections.CollectionRegistrationSource+<>c__DisplayClass4.<RegistrationsFor>b__0 (IComponentContext c, IEnumerable`1 p) [0x00000] in <filename unknown>:0 
  at Autofac.Core.Activators.Delegate.DelegateActivator.ActivateInstance (IComponentContext context, IEnumerable`1 parameters) [0x00000] in <filename unknown>:0 
  at Autofac.Core.Resolving.InstanceLookup.Activate (IEnumerable`1 parameters) [0x00000] in <filename unknown>:0 
  at Autofac.Core.Resolving.InstanceLookup.Execute () [0x00000] in <filename unknown>:0 
  at
 Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance (ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters) [0x00000] in <filename unknown>:0 
  at Autofac.Core.Resolving.ResolveOperation.ResolveComponent (IComponentRegistration registration, IEnumerable`1 parameters) [0x00000] in <filename unknown>:0 
  at Autofac.Core.Resolving.ResolveOperation.Execute (IComponentRegistration registration, IEnumerable`1 parameters) [0x00000] in <filename unknown>:0 
The program 'Mono' has exited with code 0 (0x0).
Debugging session ended.

How can we add support for HTTP/2 with HttpClient?

$
0
0

Hi All.
I have tried to set request.Version=new Version("2.0") in SendAsync method but got an error
"Only HTTP/1.0 and HTTP/1.1 version requests are currently supported. "
I am using native handlers on both platforms.

[iOS] Is anyone else having Autofac Constructor Resolving issues after the latest Xamarin update?

$
0
0

Yesterday, after updating to the latest version of Xamarin (both VS and XS), now my app won't start on iOS (still fine on Android) with the following exception. (did not fail prior to the update)

Autofac.Core.DependencyResolutionException: No constructors on type 'FutureState.AppCore.Migrations.Migration001' can be found with the constructor finder 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder'.

I even went ahead and changed the constructor to utilize service location

public Migration001(){
    _someService = App.Container.Resolve<SomeService>();
}

and got the exact same crash (iOS only).

Is anyone else seeing this? Is it an underlying issue in the latest release of Xamarin, or does Autofac need a tweak?

2014-09-04 10:04:42.288 FutureStateBreathingRoomiOS[2042:60b] Unhandled managed exception: No constructors on type 'FutureState.AppCore.Migrations.Migration001' can be found with the constructor finder 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder'. (Autofac.Core.DependencyResolutionException)
  at Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance (IComponentContext context, IEnumerable`1 parameters) [0x00000] in <filename unknown>:0 
  at Autofac.Core.Resolving.InstanceLookup.Activate (IEnumerable`1 parameters) [0x00000] in <filename unknown>:0 
  at Autofac.Core.Resolving.InstanceLookup.Execute () [0x00000] in <filename unknown>:0 
  at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance (ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters) [0x00000] in <filename unknown>:0 
  at Autofac.Core.Resolving.InstanceLookup.ResolveComponent (IComponentRegistration registration, IEnumerable`1 parameters) [0x00000] in
 <filename unknown>:0 
  at Autofac.Features.Collections.CollectionRegistrationSource+<>c__DisplayClass4+<>c__DisplayClass6.<RegistrationsFor>b__1 (IComponentRegistration cr) [0x00000] in <filename unknown>:0 
  at System.Linq.Enumerable+<CreateSelectIterator>c__Iterator10`2[Autofac.Core.IComponentRegistration,System.Object].MoveNext () [0x00000] in <filename unknown>:0 
  at System.Linq.Enumerable.ToArray[Object] (IEnumerable`1 source) [0x00000] in <filename unknown>:0 
  at Autofac.Features.Collections.CollectionRegistrationSource+<>c__DisplayClass4.<RegistrationsFor>b__0 (IComponentContext c, IEnumerable`1 p) [0x00000] in <filename unknown>:0 
  at Autofac.Core.Activators.Delegate.DelegateActivator.ActivateInstance (IComponentContext context, IEnumerable`1 parameters) [0x00000] in <filename unknown>:0 
  at Autofac.Core.Resolving.InstanceLookup.Activate (IEnumerable`1 parameters) [0x00000] in <filename unknown>:0 
  at Autofac.Core.Resolving.InstanceLookup.Execute () [0x00000] in <filename unknown>:0 
  at
 Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance (ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters) [0x00000] in <filename unknown>:0 
  at Autofac.Core.Resolving.ResolveOperation.ResolveComponent (IComponentRegistration registration, IEnumerable`1 parameters) [0x00000] in <filename unknown>:0 
  at Autofac.Core.Resolving.ResolveOperation.Execute (IComponentRegistration registration, IEnumerable`1 parameters) [0x00000] in <filename unknown>:0 
The program 'Mono' has exited with code 0 (0x0).
Debugging session ended.

Running my xamarin forms project from the command line?

$
0
0

How can I run my xamarin forms project on iOS simulator via command line (terminal on mac)?

I have seen usage of mono, msbuild and dotnet.


Xamarin Forms Android app won't compile with Material - Error retrieving parent for item

$
0
0

I have an app that was working until I added the Xamarin.Forms.Visual.Material packages to it. iOS is OK, but it won't compile on Android.

I'm following this guide: https://devblogs.microsoft.com/xamarin/beautiful-material-design-android-ios/

On the project properties, the Application tab has "Compile using Android version (Target framework): " set to Android 9.0 (Pie). In the Manifest, Minimum Android version is 5.0 (API Level 21 - Lollipop) and Target Android version is Android 9.0 (API Level 28 - Pie).

In the Android project, MainActivity.cs is a FormsAppCompatActivity and has these lines:

global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
global::Xamarin.Forms.FormsMaterial.Init(this, savedInstanceState);

And these are the errors I get at build time. There are six total that reference styles.xml

Error retrieving parent for item: No resource found that matches the given name 'Widget.MaterialComponents.TextInputLayout.FilledBox'.
Error retrieving parent for item: No resource found that matches the given name 'Widget.MaterialComponents.Button.OutlinedButton'.
Error retrieving parent for item: No resource found that matches the given name 'Theme.MaterialComponents.Light.DarkActionBar'.
No resource found that matches the given name: attr 'boxCollapsedPaddingTop'.
Error retrieving parent for item: No resource found that matches the given name 'Widget.MaterialComponents.Button'.
No resource found that matches the given name: attr 'materialButtonStyle'.

The styles.xml file in my project is VERY DIFFERENT than styles.xml in my obj\debug folder. First is what's in my project then is what's in the obj\debug folder. I have deleted the bin and obj folders from the Android project to force them to be regenerated and the result is still the same.

Any suggestions are very welcome. It seems like I've done everything in the guide I linked above.

<?xml version="1.0" encoding="UTF-8"?>

<resources>
  <style name="MyTheme" parent="MyTheme.Base">
  </style>
  <!-- Base theme applied no matter what API -->
  <style name="MyTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
    <!--If you are using revision 22.1 please use just windowNoTitle. Without android:-->
    <item name="windowNoTitle">true</item>
    <!--We will be using the toolbar so no need to show ActionBar-->
    <item name="windowActionBar">false</item>
    <!-- Set theme colors from http://www.google.com/design/spec/style/color.html#color-color-palette-->
    <!-- colorPrimary is used for the default action bar background -->
    <item name="colorPrimary">#3F51B5</item>
    <!-- colorPrimaryDark is used for the status bar -->
    <item name="colorPrimaryDark">#3F51B5</item>
    <!-- colorAccent is used as the default value for colorControlActivated
         which is used to tint widgets -->
    <item name="colorAccent">#FFA500</item>
    <!-- You can also set colorControlNormal, colorControlActivated
         colorControlHighlight and colorSwitchThumbNormal. -->
    <item name="windowActionModeOverlay">true</item>
    <item name="android:datePickerDialogTheme">@style/AppCompatDialogStyle</item>
    <item name="android:navigationBarColor">#3F51B5</item>
  </style>

  <style name="AppCompatDialogStyle" parent="Theme.AppCompat.Light.Dialog">
    <item name="colorAccent">#FFA500</item>
  </style>
</resources>

obj\debug version:

<?xml version="1.0" encoding="UTF-8"?>
<resources>
   <attr name="materialOutlinedButtonStyle" format="reference" />
   <attr name="materialSliderStyle" format="reference" />
   <attr name="materialProgressBarHorizontalStyle" format="reference" />
   <attr name="materialProgressBarCircularStyle" format="reference" />
   <!-- Material Base Theme -->
   <style name="XamarinFormsMaterialTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">
      <item name="materialButtonStyle">@style/XamarinFormsMaterialButton</item>
      <item name="materialOutlinedButtonStyle">@style/XamarinFormsMaterialButtonOutlined</item>
      <item name="materialSliderStyle">@style/XamarinFormsMaterialSlider</item>
      <item name="materialProgressBarHorizontalStyle">@style/XamarinFormsMaterialProgressBarHorizontal</item>
      <item name="materialProgressBarCircularStyle">@style/XamarinFormsMaterialProgressBarCircular</item>
   </style>
   <!-- Material Sliders -->
   <style name="XamarinFormsMaterialSlider" parent="Widget.AppCompat.SeekBar" />
   <!-- Material Progress Bars -->
   <style name="XamarinFormsMaterialProgressBarHorizontal" parent="Widget.AppCompat.ProgressBar.Horizontal">
      <item name="android:indeterminateOnly">false</item>
      <item name="android:progressDrawable">@drawable/materialprogressbar</item>
   </style>
   <style name="XamarinFormsMaterialProgressBarCircular" parent="Widget.AppCompat.ProgressBar" />
   <!-- Material Buttons (All Styles) -->
   <style name="XamarinFormsMaterialButton" parent="Widget.MaterialComponents.Button">
      <item name="android:insetTop">0dp</item>
      <item name="android:insetBottom">0dp</item>
      <item name="android:minHeight">36dp</item>
      <item name="android:paddingTop">8dp</item>
      <item name="android:paddingBottom">8dp</item>
   </style>
   <style name="XamarinFormsMaterialButtonOutlined" parent="Widget.MaterialComponents.Button.OutlinedButton">
      <item name="android:insetTop">0dp</item>
      <item name="android:insetBottom">0dp</item>
      <item name="android:minHeight">36dp</item>
      <item name="android:paddingTop">8dp</item>
      <item name="android:paddingBottom">8dp</item>
   </style>
   <style name="XamarinFormsMaterialEntryFilled" parent="Widget.MaterialComponents.TextInputLayout.FilledBox">
      <item name="boxCollapsedPaddingTop">8dp</item>
   </style>
</resources>

Preventing "Sleep mode" - Keeping the app alive

$
0
0

When my app has been startet, it shouldn't be sent to background by display-timeouts or whatever. So I want to deactivate the "Sleep mode" of the phone or tablet by code. Does anybody have some tips for me?

Picker in a list - BUG ?

$
0
0

I'm seeing some strange behaviour in our app which I can't get my head around.

We have multiple pickers in our app - they are all using a piece of code I found for a BindablePicker as we developed this prior to Xamarin having a picker control that was capable of Binding - regardless - I have changed the code to use the Xamarin picker control and am seeing the same behaviour - so I'll describe what is happening with the Xamarin picker. This is example code for our picker:

<Picker ItemsSource="{Binding checklistAnswers}" ItemDisplayBinding="{Binding Name}" HeightRequest="35" SelectedItem="{Binding selectedAnswer}"/>

So one of our tab pages has a list control on it and in in each object in the list is a set of controls consisting of a few labels, one picker and one textbox.

When I go to the first object and click its picker in the list - I can set the options for that picker.
When I go to the second object and click its picker - I see the set of options and pick one, then it shows me the set of options for the first picker for some reason - if I choose something different to what is set in the first picker - it then shows me the set of options for the second picker again - this will continue in a forever loop unless I either press Cancel on the options or pick the same value as what is currently there.

This is driving me mad, because this is apparently in our public release (although nobody has yet reported it) - and obviously would make our app look bad. I've tested on physical and emulated phones - same thing, I've tested from Android 5.x to 9.0 - same thing, I've used different devices - same thing.

Anyone run into this?

This is complete code for full detail:

<ListView x:Name="checklistList" ItemsSource="{Binding Job.ChecklistItems}" SeparatorVisibility="Default" SeparatorColor ="Black" HasUnevenRows="True" Margin="3,6">
  <ListView.ItemTemplate>
    <DataTemplate>
      <local:SxTransparentViewCell>
        <Grid Margin="10,3,10,3" Padding="1" BackgroundColor="#898989">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
          </Grid.ColumnDefinitions>
          <StackLayout BackgroundColor="White"/>
            <StackLayout Orientation="Vertical" Spacing="4" Padding="10,7,5,15">
          <Label Text="{Binding question}"/>
                   <Picker ItemsSource="{Binding checklistAnswers}" ItemDisplayBinding="{Binding Name}" HeightRequest="35" SelectedItem="{Binding selectedAnswer}"/>
          <Label Text="Notes:"/>
          <Editor x:Name="notesBox" TextColor="{StaticResource sx_normal_text}" HeightRequest="100" Text="{Binding editedNotes}"
              local:DisabledEffect.IsDisabled="{Binding canEnterNotes, Converter={StaticResource cnvInvertBool}}"/>
          </StackLayout>
      </Grid>
    </local:SxTransparentViewCell>
  </DataTemplate>
</ListView.ItemTemplate>
</ListView>

Uploading Image to server using xamarin.forms

$
0
0

Hi Xamarin Forum
im having trouble uploading my image to my server here is my code that im using right now

string[] fileTypes = null;
            var path = CrossFilePicker.Current.PickFile(fileTypes);
            using (var webClient = new System.Net.WebClient())
            {
                try
                {
                    webClient.Headers.Add("Content-Type", "binary/octet-stream");
                    byte[] result = webClient.UploadFile("http://xxx.xx.x.xx:8087/uploadFolder/", "POST", path.ToString());
                    string Result_msg = System.Text.Encoding.UTF8.GetString(result, 0, result.Length);
                }
                catch(Exception ex)
                {

                }
            }

And im having this kind of error when uploading

An exception occurred during a WebClient request.

Thanks

No Property, Bindable Property or Event Found Error

$
0
0

Hello Guys,

I try bind property of my сustom Сlock to property in ClockViewModel file. But I get this error: "No Property, Bindable Property or Event Found".
Please help.

View:

...           
                    <ContentPage.Resources>
                        <local:TimeZoneConverter x:Key="TimeZoneConverter" />
                    </ContentPage.Resources>
                    <StackLayout>
                        <local:Clock x:Name="clock"
                                     Margin="0, 50, 0, 0"
                                     HorizontalOptions="Center"
                                     VerticalOptions="Start"
                                     WidthRequest="200"
                                     HeightRequest="200"
                                     HeadColor="{Binding ClockHeadColor, Mode=TwoWay}"
                                     ClockFaceColor="{Binding ClockFaceColor, Mode=TwoWay}"

                                     ClockTimeZoneInfo="{Binding ClockTimeZoneInfo}"  <---- "No Property, Bindable Property or Event Found".

                                     />
                        <Picker Title="Изменить цвет стрелок"                     
                                    VerticalOptions="Center"
                                    Margin="0, 100, 0, 0"
                                    ItemsSource="{Binding Colors, Mode=OneWay}"
                                    SelectedItem="{Binding ClockHeadSelected, Mode=TwoWay}"/>

                </ContentPage>

Custom Clock class:

    ...
      private TimeZoneInfo timeZoneInfo = TimeZoneInfo.Local;

    public static readonly BindableProperty TimeZoneProperty =
              BindableProperty.Create(nameof(ClockTimeZoneInfo), typeof(TimeZoneInfo), typeof(Clock), TimeZoneInfo.Local,
              propertyChanging: (currentControl, oldValue, newValue) =>
              {
                  var thisControl = currentControl as Clock;
                  thisControl.ClockTimeZoneInfo = (TimeZoneInfo)newValue;
              });


            public TimeZoneInfo ClockTimeZoneInfo
            {
                get { return (TimeZoneInfo)GetValue(TimeZoneProperty); }
                set
                {
                    SetValue(TimeZoneProperty, value);
                    timeZoneInfo = value;
                    InvalidateSurface();
                }
            }
    ...

ClockViewModel:

public class ClockViewModel : INotifyPropertyChanged
    {       
        public ClockViewModel()
        {                      
        }

        public event PropertyChangedEventHandler PropertyChanged;

public TimeZoneInfo ClockTimeZoneInfo
        {
            get { return clockTimeZoneInfo; }
            set
            {
                if (clockTimeZoneInfo != value)
                {
                    clockTimeZoneInfo = value;
                    OnPropertyChanged(nameof(ClockTimeZoneInfo));
                }
            }
        }

 protected void OnPropertyChanged(string propName)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(propName));
        }
}

...

Viewing all 91519 articles
Browse latest View live


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