我有一个TextBlock
inWPF
并将 text 属性绑定TextBlock
到多依赖属性。我想有条件地绑定这些依赖属性。换句话说,我想每次将一些依赖属性绑定到TextBlock
对象的文本属性。我能怎么做?
编辑1:
我TextBlock
的在下面。我通过调查绑定依赖属性的值来计算这个文本块的文本属性。并希望通过更改每个绑定依赖属性来刷新文本块的文本。一些绑定依赖属性可能是空值,我不想将此依赖属性绑定到我的文本属性。当我调试我的应用程序并且依赖属性为空时,Visual Studio 在输出窗口中引发警告。
<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>