0

I've got an issue that the TextBlock not showing fully while the string is more than 1000 characters.

I've tried use this code

ScrollViewer.HorizontalScrollBarVisibility="Disabled"

or

VerticalAlignment="Stretch" on my TextBlock

or use this code

<ListBox ItemsSource="{Binding ArticleDataDetail}" ScrollViewer.VerticalScrollBarVisibility="Visible">
<ListBox.ItemTemplate>
    <DataTemplate>

        <StackPanel Orientation="Vertical">
            <TextBlock Text="{Binding TaxoName}" Style="{StaticResource PhoneTextNormalStyle}" Foreground="#FF2976B9"/>
            <TextBlock Text="{Binding Title}" FontWeight="Bold" TextWrapping="Wrap" Style="{StaticResource PhoneTextTitle3Style}"/>
            <Image Source="{Binding Picture}" Width="auto" Name="articleImage" Margin="10"/>
            <TextBlock Text="{Binding Content}" TextWrapping="Wrap"></TextBlock>
         </StackPanel>

    </DataTemplate>
</ListBox.ItemTemplate>
</ListBox>

But It still not show.

my code:

<Grid Margin="12,0,12,0" DataContext="{Binding ArticleDataDetail[0]}">
    <ScrollViewer HorizontalScrollBarVisibility="Disabled">
        <StackPanel>
            <TextBlock Text="{Binding Content}" TextWrapping="Wrap" VerticalAlignment="Stretch"></TextBlock>
            <TextBlock Text="GeuT"></TextBlock>
        </StackPanel>
    </ScrollViewer>
</Grid>
PHP Java Eng
  • 81
  • 1
  • 1
  • 5
  • Are you sure your datasource stores more than 1000 characters? Also, you may want to check this question out ... http://stackoverflow.com/questions/9779858/set-the-maximum-chr-length-of-a-textblock-in-xaml – 3-14159265358979323846264 Jul 14 '15 at 10:24
  • What do you mean with "not showing fully"? Can you add a screenshot of what's happening? – almulo Jul 14 '15 at 10:38
  • I can't attach an image here coz, my reputation's not qualified.. but here's the link http://i.stack.imgur.com/hfnbQ.png – PHP Java Eng Jul 27 '15 at 08:40
  • @3-14159265358979323846264 sorry, but I think that question's not what I mean here.. :D the question is how about set a limit for textblock, but for my case, textblock like not showing a whole of my content. here's my screenshot.. :D – PHP Java Eng Jul 27 '15 at 08:44

2 Answers2

1

Do you mean the TextBlock in the ItemTemplate? If it's the case maybe this helps:

Set the HorizontalContentAlignment attribute of the ListBox to "Stretch":

<ListBox ... HorizontalContentAlignment="Stretch"></ListBox>

I'm just guessing what your problem is, so if it's not the case I think you should make your question clearer: rephrase it or add some illustrating images.

0

Another thing I could think of - without a screenshot - is that maybe the Textblock is too small to fit all the content and that it would have to be scrollable.

Scrollbars don't appear automatically if the text exceeds the display item size limits. You can enable them by adding the following properties to your TextBlocks:

ScrollViewer.VerticalScrollMode="Auto" ScrollViewer.VerticalScrollBarVisibility="Visible"

Kristina
  • 91
  • 3
  • I also tried this on my code.. but not working too.. here's my screenshot http://i.stack.imgur.com/hfnbQ.png – PHP Java Eng Jul 27 '15 at 08:38
  • According to the original post your Code is: - that means that you have no horizontal scroll bar, but it doesn't enable the vertical scroll bar yet. Also, it seems that the height of the Textblock (and maybe grid row?) is limited - how about setting it to Auto? – Kristina Jul 27 '15 at 11:16
  • Is it a learning project? If it's not critical, maybe you can upload the project files somewhere, like github, and I could possibly have a look at them? – Kristina Jul 27 '15 at 18:48