I'm working on a new WPF form. I'm using the Extended.Wpf.Toolkit's MaskedTextBox. I'm using the IsMaskCompleted property in a MultiBinding expression. Here's the XAML:
<Border Grid.Row="1"
Grid.Column="1">
<Border.BorderThickness>
<MultiBinding Converter="{StaticResource multiBoolToThicknessConverter}">
<Binding ElementName="TargetMaskedTextBox, Path=IsMaskCompleted" />
<Binding Path="IsTargetCompleted" />
</MultiBinding>
</Border.BorderThickness>
<tk:MaskedTextBox x:Name="TargetMaskedTextBox"
Style="{StaticResource LeftAlignMaskedTextBoxStyle}"
Value="{Binding Target}"
IsEnabled="{Binding IsTargetEnabled}"
ValueDataType="{x:Type System:Single}"
Mask="\0.0##" />
</Border>
and here's the Convert method in my IMultiValueConverter:
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
try
{
bool? boolOneNullable = values[0] as bool?;
bool? boolTwoNullable = values[1] as bool?;
bool boolOne = true;
bool boolTwo = true;
if (!boolOneNullable.HasValue)
{
boolOne = false;
}
else
{
boolOne = boolOneNullable.Value;
}
if (!boolTwoNullable.HasValue)
{
boolTwo = false;
}
else
{
boolTwo = boolTwoNullable.Value;
}
var combinedBools = boolOne && boolTwo;
if (combinedBools)
{
return new Thickness(0);
}
else
{
return new Thickness(1);
}
}
catch (Exception)
{
return null;
}
}
What I don't understand is that when selecting a row in a datagrid, which populates the MaskedTextBox control, the IsMaskCompleted will often be null, even though there's valid data within it. Why is that?