【发布时间】:2019-07-17 04:40:10
【问题描述】:
我创建了一个使用电话掩码的行为。当显式插入掩码时,它工作正常。但是当我在选择器中更改电话类型时,我想与视图模型通信以更改掩码。
在 xaml 文件中:
<Picker
x:Name="picker_cadastronotificacao_tipotelefone"
Title="{x:Static local:AppResources.picker_cadastronotificacao_tipotelefone}"
Style="{StaticResource Picker}"
SelectedItem="{Binding TipoTelefoneSelecionado}">
<Picker.Items>
<x:String>Celular</x:String>
<x:String>Telefone Fixo</x:String>
</Picker.Items>
</Picker>
<Entry
x:Name="entry_cadastronotificacao_telefone"
Placeholder="{x:Static local:AppResources.entry_cadastronotificacao_telefone}"
Style="{StaticResource EntradasTexto}"
Text="{Binding Telefone}"
Keyboard="Telephone"
IsEnabled="{Binding HabilitarCampoTelefone}">
<Entry.Behaviors>
<behavior:MaskBehavior Mascara="{Binding MascaraTelefone}"/>
</Entry.Behaviors>
</Entry>
在视图模型中:
if (TipoTelefoneSelecionado == "Telefone Fixo")
MascaraTelefone = "(XX) XXXX - XXXX";
else if(TipoTelefoneSelecionado == "Celular")
MascaraTelefone = "(XX) XXXXX - XXXX";
错误:找不到“睫毛膏”的属性、可绑定属性或事件,或者值和属性之间的类型不匹配。
【问题讨论】:
标签: c# xaml xamarin.forms