I have a TextBlock
in WPF
and binding text property of this TextBlock
to multi dependency property.
I want to bind these dependency property conditional. in other word I want to bind each time some dependency property to text property of TextBlock
object. How can I do?
Edit1 :
My TextBlock
is below. I calculate text property of this textblock by survey values of binding dependency properties. and want to refresh text of textblock by change each of binding dependency properties. some of binding dependency property may be null value and I don't want to binding this dependency property to my text property. When I debug my application and dependency property was null Visual studio raise warning in output window.
<TextBlock>
<TextBlock.Text>
<MultiBinding Converter="{StaticResource OCDFLinkTextConverter}">
<Binding Path="TbOCDFLink" RelativeSource="{RelativeSource AncestorType=ocdfcontrol:OCDFLink}"/>
<Binding Path="TbOCDFLink.FromOCDFObjectItem.OCDFObject.XPosition" RelativeSource="{RelativeSource AncestorType=ocdfcontrol:OCDFLink}"/>
<Binding Path="TbOCDFLink.FromOCDFObjectItem.OCDFObject.YPosition" RelativeSource="{RelativeSource AncestorType=ocdfcontrol:OCDFLink}"/>
<Binding Path="TbOCDFLink.ToOCDFObjectItem.OCDFObject.XPosition" RelativeSource="{RelativeSource AncestorType=ocdfcontrol:OCDFLink}"/>
<Binding Path="TbOCDFLink.ToOCDFObjectItem.OCDFObject.YPosition" RelativeSource="{RelativeSource AncestorType=ocdfcontrol:OCDFLink}"/>
<Binding Path="TbOCDFLink.FromOCDFObjectItem.OCDFObject.ParentOCDFObject.XPosition" RelativeSource="{RelativeSource AncestorType=ocdfcontrol:OCDFLink}"/>
<Binding Path="TbOCDFLink.FromOCDFObjectItem.OCDFObject.ParentOCDFObject.YPosition" RelativeSource="{RelativeSource AncestorType=ocdfcontrol:OCDFLink}"/>
<Binding Path="TbOCDFLink.ToOCDFObjectItem.OCDFObject.ParentOCDFObject.XPosition" RelativeSource="{RelativeSource AncestorType=ocdfcontrol:OCDFLink}"/>
<Binding Path="TbOCDFLink.ToOCDFObjectItem.OCDFObject.ParentOCDFObject.YPosition" RelativeSource="{RelativeSource AncestorType=ocdfcontrol:OCDFLink}"/>
<Binding Path="TbOCDFLink.TbOCDFLinkGroup.FromOCDFObjectItem" RelativeSource="{RelativeSource AncestorType=ocdfcontrol:OCDFLink}"/>
<Binding Path="TbOCDFLink.TbOCDFLinkGroup.ToOCDFObjectItem" RelativeSource="{RelativeSource AncestorType=ocdfcontrol:OCDFLink}"/>
</MultiBinding>
</TextBlock.Text>
</TextBlock>
Hi try this in your converter
public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
string result="";
if (values != null)
{
foreach (var val in values)
{
if (val == null)
continue;
else
result = result + val;
}
}
return result;
}
I Expect your all binding is working.I hope this will help.