在我的应用程序中,我有一个文本框,用户在其上键入数字。我希望这个拉丁文编号为波斯语,作为用户输入。在调用RaisePropertychanged
之后,getter
的{{1}}未被调用,因此App Ui不会更新。我的代码有什么问题?
这是我的代码
MobileNumber
<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>
答案 0 :(得分:0)
尝试将RaisePropertyChanged
行更改为RaisePropertyChanged("MobileNumber");
如果您使用MVVM-Light Code片段(如果已安装,您可以开始输入mvvm,并且会弹出intellisense),您可以查看mvvmpinpc
这是PropertyChanged
个代码段之一。您可以Tab
通过不同的模板字段将其设置为您想要的内容,并且可以为您的编码生活更轻松地提供一些小技巧和窍门。