views:

357

answers:

2

Is there any way to use databinding to show or hide a Paragraph within a FlowDocument? (I want to use MVVM, but with a FlowDocument as my view.)

Paragraph doesn't have a Visibility property. I'm not sure what else to look for.

A: 

Options I can think of...

  1. Hide the content of the paragraph (don't include the paragraph in your model)
  2. Extend Paragraph (or one of its base classes) and provide a dependency property for IsVisible
Will
If the Paragraph has no content, then it still takes up a full line worth of vertical space, which I'd rather avoid. As for adding an IsVisible property, how would it be implemented?
Joe White
+1  A: 

I had the exact same problem and handled it successfully by wrapping the content of the ListItem in a InlineUIContainer, like so:

  <ListItem>
    <Paragraph>
      <InlineUIContainer>
        <TextBlock x:Name="HideMe" Visibility="Collapsed">
          <Hyperlink NavigateUri="...">Components</Hyperlink>
        </TextBlock>
      </InlineUIContainer>
    </Paragraph>
  </ListItem>

From here you can set the visbility of "HideMe" in code or through a binding.

Chris Bova