使用密码框或任何形式的常规文本控件时,我似乎无法访问这些属性。我已经设置了一个值转换器,它会在更新时正确返回值,但是一旦为我的按钮触发命令,参数似乎被重置为 null。
XAML
<Button x:Name="RegisterButton" Content="register" Height="28" Margin="0,0,8,8" VerticalAlignment="Bottom" Background="#FF005D99" BorderBrush="White" Foreground="White" FontSize="13.333" TextOptions.TextFormattingMode="Display" FontFamily="/Agile Project Management Tool 2012;component/Fonts/#Segoe UI" Padding="1,0,1,1" HorizontalAlignment="Right" Width="90" Command="{Binding RegisterCommand}">
<Button.CommandParameter>
<MultiBinding Converter="{StaticResource ParamConverter}">
<Binding ElementName="EmailTextInput" Path="Text"/>
<Binding ElementName="PhoneTextInput" Path="Text"/>
</MultiBinding>
</Button.CommandParameter>
</Button>
值转换器
class TwoParamConverter : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
return values;
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
查看模型
public ResigtrationViewModel()
{
_browsePicturesCommand = new DelegateCommand(OnBrowsePicturesCommand);
_registerCommand = new DelegateCommand<object>(OnRegisterCommand);
}
private void OnRegisterCommand(object paramaters)
{
var values = (object[])paramaters;
var a = (string)values[0];
var b = (string)values[1];
MessageBox.Show(a);
MessageBox.Show(b);
}
但是,当我在 OnRegisterCommand 调用中检查参数时,它们似乎为空。
任何帮助,将不胜感激!!