In my VM I am assigning value to CurrentItem.SecondValue when Toggle is checked it gets whatever value is entered in FirstValue Entry, but value is not getting updated in UI unless I refresh it/navigate between pages. When I debug it I see that CurrentItem.SecondValue is updated in VM. Any suggestions how it can be fixed?
XAML:
<renderer:CustomKeyEntry x:Name="FirstValue" Text="{Binding CurrentItem.FirstValue}" HeightRequest="40" WidthRequest="250" BackgroundColor="#FFFFFF" Margin="15, 0" TextColor="Black" IsEnabled="{Binding IsThisEnabled}" ReturnType="Next" />
<common:Toggle Text="{i18n:Translate Use_This_Number}" Checked="{Binding SecondValueIsFirstValue}" TextColor="Gray" HorizontalOptions="EndAndExpand" IsEnabled="{Binding IsThisEnabled}" Margin="0,0,10,0" />
<renderer:CustomKeyEntry x:Name="SecondValue" Text="{Binding CurrentItem.SecondValue}" HeightRequest="40" WidthRequest="250" BackgroundColor="#FFFFFF" Margin="15, 0" TextColor="Black" ReturnType="Next"/>
ViewModel:
private Boolean _secondValueIsFirstValue= false;
public Boolean SecondValueIsFirstValue
{
get { return _secondValueIsFirstValue; }
set
{
if (_secondValueIsFirstValue!= value)
{
if (value)
{
CurrentItem.SecondValue = CurrentItem.FirstValue;
OnPropertyChanged();
}
SetProperty(ref _secondValueIsFirstValue, value);
}
}
}
private ItemDTO _currentItem;
public ItemDTO CurrentItem
{
get { return _currentItem;}
set { SetProperty(ref _currentItem, value); }
}
//DTO Class
public class ItemDTO : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
....
}