Using Snoop , you can see that it is from ContainerVisual , which wraps your child TextBlock s. Because TextBlock trying to display a collection of derived Inline objects (this is abstracted out altogether), it should wrap your TextBlock in ContainerVisual .
Since these are actual objects ordered by the parent TextBlock , and they donβt even have the Visibility property, you have to reorganize your code a bit. I assume that you are trying to bind to several separate properties and want to display them in one TextBlock. You can fix this in several ways:
- Make an
IMultiValueConverter and pass a bunch of properties that control what to show - Build complex string in
ViewModel - Replace the external
TextBlock with the StackPanel with Orientation="Horizontal"
I would recommend the latter, as this is the easiest.
<StackPanel> <StackPanel Orientation="Horizontal"> <TextBlock>Block 1</TextBlock> <TextBlock>Block 2</TextBlock> </StackPanel> <StackPanel Orientation="Horizontal"> <TextBlock Visibility="Collapsed">Block 3</TextBlock> <TextBlock>Block 4</TextBlock> </StackPanel> <StackPanel Orientation="Horizontal"> <TextBlock>Block 5</TextBlock> <TextBlock>Block 6</TextBlock> </StackPanel> </StackPanel>
source share