0
Answer

Dividing truncated text into multiple textblocks to appear i

JOHN JOHNNNY

JOHN JOHNNNY

8y
347
1

Hi
Using the below code in my app the text is truncated, i think it exceeds the
2048x2048 pixels. when i googled a solution i was told to divide up my text
into multiple blocks to display it all. Can anyone please show me how to do this
see my code below

xaml
<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">

<ScrollViewer Padding="10" Height="Auto" VerticalScrollBarVisibility="Auto">
<TextBlock x:Name="textblock" TextWrapping="Wrap" Foreground="Black" Height="Auto" FontSize="40" />
</ScrollViewer>

</Grid>


xaml.cs
namespace DevotionJson
{
public partial class BibleInYear : PhoneApplicationPage
{

private List<BibleData> devotions;

public BibleInYear()
{
InitializeComponent();

devotions = new List<BibleData>();
AddDevotions();
}

protected override void OnNavigatedTo(NavigationEventArgs e)
{
DateTime dt = DateTime.Now;
int month = dt.Month;
int year = dt.Year;
int index;

if (DateTime.IsLeapYear(year) || (month <= 2))
{
index = dt.DayOfYear - 1; // list is indexed from 0
}
else
{
index = dt.DayOfYear; // add a day
}

textblock.Text = devotions[index].ToString(); // or some other property
}

private void AddDevotions()
{
for (int i = 1; i <= 366; i++)
{
string filePath = "BibleInYear/Bible" + i.ToString() + ".json";
BibleData d = ReadJsonFile(filePath);
devotions.Add(d);
}
}

public BibleData ReadJsonFile(string JsonfilePath)
{
BibleData[] d = null;

using (StreamReader r = new StreamReader(JsonfilePath))
{
string json = r.ReadToEnd();
d = JsonConvert.DeserializeObject<BibleData[]>(json);
}
return d[0];
}

}
}

Kindly help