c# - Throttling KVO bindings (Xamarin / Mac ) -


i have mac desktop app in xamarin.

there kvo model ui bound using interface builder.

i listen out changes values in model, , when changed, update attached hardware new value on serial port connection.

the problem have sliders. bound value on slider updates on every step of slider, rather when user releases slider. want can update text field showing value, don't want trigger handler until release.

i can set slider continuous = false, solves handler issue, textfield updates on release.

i can't see anyway configure binding trigger once user finishes sliding, or way throttle bound callback, runs once within given timeframe.

  • can trigger binding update once user releases mouse?
  • is there way throttle callback?
  • would better practice listen out ui events update hardware? rather bound model value changes?

below current set up.....

enter image description here

in settings model

[register("settingsmodel")] public class camerasettingsmodel : nsobject {     export("gainmode")]     public int gainmode { get; set; } } 

interface builder settings

interface builder settings

in view controller...

manually make var holding settings model kvo compliant well. (the settings model gets swapped out different models depending on user settings, needs trigger willchange etc bindings refresh)

 private camerasettingsmodel _settings;     [export("settings")]     public camerasettingsmodel settings     {                  {              return _settings;          }         set          {              willchangevalue("settings");              _settings = value;              didchangevalue("settings");          }     } 

listen out changes

   settings.addobserver("gainvalue", nskeyvalueobservingoptions.new, updategainvalue);  

update hardware

   private void updategainvalue(nsobservedchange obj)     {         //update hardware here     } 


Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -