I have a Xamarin.Forms application. It is using freshmvvm framework, which is not relevant for my issue. A page has a couple of Entries:
<Entry Placeholder="Width" Text="{Binding TileWidth, Mode=TwoWay}" />
<Entry Placeholder="Height" Text="{Binding TileHeight, Mode=TwoWay}" />
These entries are bound to the ViewModel properties:
int _tileWidth;
public int TileWidth
{
get => _tileWidth;
set
{
_tileWidth = value;
RaisePropertyChanged(nameof(TileWidth));
}
}
int _tileHeight;
public int TileHeight
{
get => _tileHeight;
set
{
_tileHeight = value;
RaisePropertyChanged(nameof(TileHeight));
}
}
If the user enters some numbers into the entries, binding sets the properties accordingly. But if after that the user DELETES a value from an entry, binding does not reset the corresponding property to 0, which causes various issues. The execution doesn't even come to the property's set part. (If the user explicitly enters 0, the bound property is set to 0 as expected).
Maybe somebody has an idea what I am missing? Thanks.
Entry.Textis astringwhile you are binding toint, maybe that is the problem. Try to use a converter orint?. - EvZ