C
C#5mo ago
Elio

MVVM TOOLKIT SetProtperty

Hello, i'm trying to had a decimal number in my textbox but i can't add a . or , to write my decimal number. here is the declaration of my property that i bind to my textbox.
private readonly SymmetricRoll _symmetricRoll;
public double RollPosition
{
get => _symmetricRoll.RollPosition;
set => SetProperty(_symmetricRoll.RollPosition, value, _symmetricRoll, (symmRoll, newValue) => symmRoll.RollPosition = newValue);
}
private readonly SymmetricRoll _symmetricRoll;
public double RollPosition
{
get => _symmetricRoll.RollPosition;
set => SetProperty(_symmetricRoll.RollPosition, value, _symmetricRoll, (symmRoll, newValue) => symmRoll.RollPosition = newValue);
}
Do i need to link my textbox to a string and then i parse this string to affect the value to RollPosition ?
3 Replies
Denis
Denis5mo ago
Have you considered using a converter directly on your binding? You can keep the property type as double And have the textbox receive a formatted string
Elio
Elio5mo ago
yeah i've already thougth about this possibility but it looks a bit weird to me to do a converter in order to take input for double
Denis
Denis5mo ago
Well one way or another you'll have to have some conversion logic to take a string and format it into a double. Even if you end up going with a custom control So I say that a converter is fine