c# - WPF: Is there workaround when value multiplies itself by 10 when backspacing over decimal point -



c# - WPF: Is there workaround when value multiplies itself by 10 when backspacing over decimal point -

i running odd issue when binding decimal value time backspace on decimal point bound value (and displayed value) multiplied 10.

essentially if have cursor right of decimal point 55.|0 nail backpace expect 5|.5 instead 550|.0

is there workaround issue allow mode=twoway, updatesourcetrigger=propertychanged behavior , decimal points beingness entered? (propertychanged desired behavior me in case, lostfocus not alternative me)

<window x:class="sandboxwpf.mainwindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:sandboxwpf="clr-namespace:sandboxwpf" title="mainwindow" height="350" width="525"> <window.datacontext> <sandboxwpf:mainviewmodel/> </window.datacontext> <stackpanel> <textbox text="{binding myval, mode=twoway, updatesourcetrigger=propertychanged, stringformat=n1}"></textbox> </stackpanel> </window>

--

namespace sandboxwpf { public class observableobject : inotifypropertychanged { public event propertychangedeventhandler propertychanged; [notifypropertychangedinvocator] protected virtual void raisepropertychanged([callermembername] string propertyname = null) { propertychangedeventhandler handler = propertychanged; if (handler != null) handler(this, new propertychangedeventargs(propertyname)); } } public class mainviewmodel : observableobject { private double _myval; public mainviewmodel() { myval = 55.0; } public double myval { { homecoming _myval; } set { raisepropertychanged(); _myval = value; } } } }

edit: ended going 'string' work around, works out have remember convert double before using '+' operator.

c# wpf

Comments

Popular posts from this blog

model view controller - MVC Rails Planning -

ruby on rails - Devise Logout Error in RoR -

html - Submenu setup with jquery and effect 'fold' -