Is it possible to use an attached property as parameter of a Multibinding? How?
I need to use the value of an attached property to change the text I bind to a TextBlock.
My code is similar to this:
TextBlock Binding
<TextBlock x:Name="myTxt"
wpfApplication2:TextBlockAttachedProperties.MyProperty="true">
<TextBlock.Text>
<MultiBinding Converter="{StaticResource CustomConverter}" Mode="TwoWay" NotifyOnValidationError="true">
<Binding Path="Test"/>
<Binding ElementName="myTxt" Path="MyProperty" Mode="OneWay"/>
</MultiBinding>
</TextBlock.Text>
My converter:
Converter Code
public class CustomConverter : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
double? value = null;
value = values[0] as double?;
DependencyProperty myProperty= null;
if (values.Count() > 1 && values[1] != DependencyProperty.UnsetValue)
//Do something
if (myProperty!= null )
{
//here do something with the value using the attached property
var convertedValue = value;
return convertedValue;
}
return value;
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
{
object[] values = { value };
return values;
}
}
However since I don't know how to pass the attached property as a parameter of the Multibinding the converter always gets DependencyProperty.UnsetValue.