, , ..
, . ( ) MultiBinding FallbackValue . , , 1, , :)
<TextBlock>
<TextBlock.Text>
<MultiBinding StringFormat="{}{0}:{1}"
Converter="{StaticResource FallbackConverter}"
FallbackValue="">
<Binding Path="MyTime.Hours" />
<Binding Path="MyTime.Minutes" />
</MultiBinding>
</TextBlock.Text>
</TextBlock>
, ""
public class FallbackConverter : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
foreach (object value in values)
{
if (value == DependencyProperty.UnsetValue)
{
return DependencyProperty.UnsetValue;
}
}
return values;
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}