in my application I have a textbox that user type a number on it. I want to this Latin number to Persian one as user type it. after calling RaisePropertychanged
the getter
of MobileNumber
not called so App Ui doesn't update. what is the problem with my code?
here is my code
<Page
x:Class="CustomName.RegistrationPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:ShahrMobileBank.Views.Masters.Registration"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:behaviors="using:Template10.Behaviors"
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
xmlns:core="using:Microsoft.Xaml.Interactions.Core"
xmlns:converter="using:ShahrMobileBank.Converter"
mc:Ignorable="d"
DataContext="{Binding Path=RegistrationPage, Source={StaticResource ViewModelLocator}}">
<StackPanel Background="{StaticResource RegistrationPageBackgroundColor}" x:Name="LayoutRoot">
<StackPanel.Resources>
<converter:RegistrationConverter x:Key="RegistrationConverter"/>
</StackPanel.Resources>
<TextBox Style="{StaticResource GenericTextBoxBeforeLogin}" x:Uid="PhoneNumber" InputScope="Number" Text="{Binding Path=MobileNumber, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" MaxLength="{StaticResource MobileNumberMaxLength}"/>
</StackPanel>
</Page>
public class RegistrationPageViewModel : ViewModelBase
{
private string _mobileNumber;
public String MobileNumber
{
get
{
return _mobileNumber;
}
set
{
_mobileNumber = LangUtil.ConvertEnNumberToFaNumber(value); // this converts the number from Latin to Persian
RaisePropertyChanged(() => MobileNumber);
}
}
}
Try changing the RaisePropertyChanged
line to RaisePropertyChanged("MobileNumber");
If you use the MVVM-Light Code snippets (if installed, you can start typing mvvm, and intellisense will pop up), you can look at mvvmpinpc
which is one of the PropertyChanged
code snippets. You can Tab
through the different template fields to set it up to what you want, as well as possibly shed any light on little tips and tricks to make your coding life easier.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.