question

HenningRichter-4454 avatar image
0 Votes"
HenningRichter-4454 asked JessieZhang-2116 edited

Xamarin Exception on showing hidden soft keyboard

Hi,
I am using Xamarin Forms 5.0.0.2012 in combination with Devexpress Xamarin Form 20.2.5 for an Android 8.1 device.
I am getting quite regularly the following exception when switching between input field and enter data within a DataFormView.
On my Android device I've hidden the virtual Keyboard globally (not part of my code).

Basically my Object look the follwoing:
[public abstract class Base : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged([CallerMemberName] string name = "")
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
}

         string baseObject;
         public string BaseObjectField { get => baseObject; set { baseObject = value; OnPropertyChanged(); } }
 }
    
 public class InheritedObject : Base
 {
         [DataFormDisplayOptions(LabelText = "Fermenter", LabelPosition = DataFormLabelPosition.Top,  IsReadOnly = false)]
         [DataFormItemPosition(RowOrder = 1, ItemOrderInRow = 2)]
         [DataFormComboBoxEditor(InplaceLabelText = "choose", IsFilterEnabled = true)]
         [ClearData]
         public new string BaseObjectField
         {
                 get => base.BaseObject;
                 set 
                 { 
                         base.BaseObject = value; 
                            if(value != null) 
                                 SomeOtherField = GetValue(value);
                 }
         }
         decimal? someotherfield;
         public decimal? SomeOtherfField { get => someotherfield; set { someotherfield = value; OnPropertyChanged() } }
    
 }
    
 public class ComboBoxDataProvider : IPickerSourceProvider
 {
     private Base baseobj;
     public ComboBoxDataProvider(Base base)
     {
         baseobj = base;
     }
    
     public IEnumerable GetSource(string propertyName)
     {
         if(propertyName.Equals("BaseObjectField")
         {
             return LocalDataStore.Instance.Lookups.BaseObjects.Select(x => x.Name);
         }
     }  
 }
    
 public class GenericModelPage<T> : ContentPage where T : Base, new() 
 {
     var masterForm = new DataFormView()
     {
         CommitMode = CommitMode.PropertyChanged,
         ValidationMode = CommitMode.LostFocus
     };

     var dto = new T();
     BindingContext = _viewModel = new GenericViewModel<T>(Navigation,  this)
     {
         DtoObject = dto
     }
     masterForm.DataObject = dto;
     masterForm.PickerSourceProvider = new ComboBoxDataProvider(dto)
 }][1]


[1]: /answers/storage/attachments/80195-exceptionstacktrace.txt

dotnet-xamarinforms
· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @HenningRichter-4454 ,what's the DataFormView and IPickerSourceProvider ? Could you please post the necessary code snippets and a basic demo to github or onedriver so that we can test on our side?

0 Votes 0 ·

Hi,
DataFormView and IPickerSourceProvider and Devexpress components. I will create a short demo and let you know when and where its uploaded.


0 Votes 0 ·

Here is the git-repository:

Exception occurs on an emulated Android 7.0 device and a real Android 8.1 device.

Steps to reproduce:

Select some Fermenter
Enter values to fields "kontin." and "Probe"
Save
Select again some Fermenter
Enter value to field "kontin."
Try to enter value to field "Probe"
Behaviour:
While clicking into the field "Probe" the unhandled exception is thrown!

Exception:
Cannot access a disposed object.
Object name: 'Android.Views.InputMethods.InputMethodManager'.'


0 Votes 0 ·

1 Answer

HenningRichter-4454 avatar image
0 Votes"
HenningRichter-4454 answered

Hi,

the Exception is caused by the DevExpress Framework. I will close this issue.
Thanks

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.