|
It seems no amount of SnapsToDevicePixels="True" and/or UseLayoutRounding="True" can make the border around a Paragraph sharp:
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<FlowDocumentReader>
<FlowDocument>
<Paragraph BorderBrush="Black" BorderThickness="1" Padding="10">
<InlineUIContainer>
<Expander Header="An expander" >
<Button>A button</Button>
</Expander>
</InlineUIContainer>
</Paragraph>
<Paragraph BorderBrush="Black" BorderThickness="1" Padding="10">
<InlineUIContainer>
<Expander Header="An expander" >
<Button>A button</Button>
</Expander>
</InlineUIContainer>
</Paragraph>
<Paragraph BorderBrush="Black" BorderThickness="1" Padding="10">
<InlineUIContainer>
<Expander Header="An expander" >
<Button>A button</Button>
</Expander>
</InlineUIContainer>
</Paragraph>
</FlowDocument>
</FlowDocumentReader>
</Window>
However i can use RenderOptions.EdgeMode="Aliased" which makes the border sharp, but distorts the Expander:
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<FlowDocumentReader RenderOptions.EdgeMode="Aliased">
<FlowDocument>
<Paragraph BorderBrush="Black" BorderThickness="1" Padding="10">
<InlineUIContainer>
<Expander Header="An expander" >
<Button>A button</Button>
</Expander>
</InlineUIContainer>
</Paragraph>
</FlowDocument>
</FlowDocumentReader>
</Window>
So, is there any way to make the border sharp without hurting the documents appearance?
|
|
|
|
|
If you placed the Expanders (with a border) "outside" the FlowDocument (in a FrameworkElement), you could use UseLayoutRounding to get the effect you want.
As presented, I don't see why these expanders have to be inside a FlowDocument (which isn't a FrameworkElement).
|
|
|
|
|
Ok i figured out a way that works, although its a bit ugly:
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<FlowDocumentScrollViewer>
<FlowDocument>
<Paragraph>
<InlineUIContainer>
<Border BorderBrush="Black" BorderThickness="1" Padding="10" SnapsToDevicePixels="True">
<Expander>
<Expander.Header>
<TextBlock Text="An expander" Width="{Binding RelativeSource={RelativeSource AncestorType={x:Type Expander}}, Path=ActualWidth}" />
</Expander.Header>
<Button>A button</Button>
</Expander>
</Border>
</InlineUIContainer>
</Paragraph>
</FlowDocument>
</FlowDocumentScrollViewer>
</Window>
As for why, my code is based on this: http://stackoverflow.com/questions/3798262/how-to-collapse-a-paragraph although i've been improving it. The idea is add or remove a paragraph block below the expander block based on the state of the expander. That + code to handle the copy to clipboard to convert the uielements to text (in this case, getting the header string of the expander) and the result is an interactive flowdocument with collapsing regions and copy support.
modified 7-Nov-12 23:32pm.
|
|
|
|