Reputation: 93
I am getting Raw text from Server API via XML parsing. i am checking that full text is going into array/list, but it gets trimmed when displayed in page inside textblock or richtextbox.
here is XAML for Listbox which contains my richtextbox:
<ListBox Name="ListboxPolicy" Background="#FF5F113C" Opacity="0.93" Foreground="#FFF5E0EC" Margin="0,137,0,0">
<ListBox.ItemTemplate>
<DataTemplate >
<StackPanel>
<!--<TextBlock x:Name="PolicyText" TextAlignment="Justify" Text="{Binding policyDetailsData}" TextWrapping="Wrap" IsHitTestVisible="False"/>-->
<RichTextBox x:Name="BoxPolicies" IsHitTestVisible="False" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" SizeChanged="BoxPolicies_SizeChanged" >
<Paragraph FontSize="24" FontWeight="Bold" Foreground="#FFDABCD5">
<Run Text="{Binding Path=policyTitleData}" />
</Paragraph>
<Paragraph FontSize="20" TextAlignment="Justify" >
<Run Text="{Binding Path=policyDetailsData}" />
</Paragraph>
<Paragraph FontSize="20">
<Run Text="-----------------------------" />
</Paragraph>
</RichTextBox>
<!--<TextBlock x:Name="PolicyHeader" Text="{Binding policyTitleData}" TextWrapping="Wrap" IsHitTestVisible="False" Foreground="#FF13090E" FontWeight="Bold" FontSize="22"/>
<TextBlock x:Name="PolicyText" Text="{Binding policyDetailsData}" TextWrapping="Wrap" IsHitTestVisible="False" FontSize="20"/>-->
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
Upvotes: 1
Views: 227
Reputation: 4198
The amount of text that could be displayed in a single TextBlock is limited for performance reasons. What worked for me was splitting the text into paragraphs, putting each in a separate TextBlock and adding all to a StackPanel.
There's an implemented solution in this blog post
Upvotes: 0
Reputation: 8654
Default Orientation Of StackPanel is Vertical and it takes height and width of child element(here RichTextBox) if you dont set Height and Width to stackpanel.
To avoid Text Trimming you need to Set StackPanel Orientation="Horizontal" and Height and Width to RichtextBox
<StackPanel Orientation="Horizontal">
<RichTextBox x:Name="BoxPolicies" IsHitTestVisible="False" Height="400" Width="400" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch">
<FlowDocument >
<Paragraph FontSize="24" FontWeight="Bold" Foreground="Red">
<Run />
</Paragraph>
<Paragraph FontSize="20" TextAlignment="Justify" >
<Run />
</Paragraph>
</FlowDocument>
</RichTextBox>
</StackPanel>
Upvotes: 1