Hi
I am using pivot template in my app to develop an app and in my xaml.cs i will like to
initialize more than one index but am getting error is there any way i can do this without getting
the following errors "a local variable index is already defined in this scope" and
"the call is ambigous between the following properties and methods"
I am doing this because my text is getting truncated at the bottom of the textblock.
i want the overflow text to continue in pivot template. see my code below
xaml
xaml.cs
namespace My_SolnForTruncation{
public partial class MainPage : PhoneApplicationPage
{
//Bible In A Year text strings code begins
List
// Constructor
public MainPage()
{
InitializeComponent();
AddBibleInYear();
int index = DateTime.Now.DayOfYear;
textblock1.Text = bible[index];
AddBibleInYear2();
int index = DateTime.Now.DayOfYear;
textblock2.Text = bible[index];
// Sample code to localize the ApplicationBar
//BuildLocalizedApplicationBar();
}
// Bible In A Year code continues
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
}
textblock1.Text = bible[index].ToString(); // or some other property
}
private void AddBibleInYear()
{
for (int i = 1; i <= 366; i++)
{
string filePath = Path.GetFullPath("BibleInYear/Bible" + i.ToString() + ".txt");
if (File.Exists(filePath))
{
bible.Add(ReadTextFile(filePath));
}
else
{
bible.Add(string.Format("BibleInYear file '{0}' was not found.", i));
}
}
}
public string ReadTextFile(string textFilePath)
{
string text = null;
using (StreamReader r = new StreamReader(textFilePath))
{
text = r.ReadToEnd();
}
return text;
}
// Bible In A Year Part 2 code continues
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
}
textblock2.Text = bible[index].ToString(); // or some other property
}
private void AddBibleInYear2()
{
for (int i = 1; i <= 366; i++)
{
string filePath = Path.GetFullPath("BibleInYear2/Bible" + i.ToString() + ".txt");
if (File.Exists(filePath))
{
bible.Add(ReadTextFile(filePath));
}
else
{
bible.Add(string.Format("BibleInYear2 file '{0}' was not found.", i));
}
}
}
public string ReadTextFile(string textFilePath)
{
string text = null;
using (StreamReader r = new StreamReader(textFilePath))
{
text = r.ReadToEnd();
}
return text;
}
Kindly help
Anupam SinghPosted Jan 29, 2016, 7:14 AM
InitializeComponent();
AddBibleInYear();
int index = DateTime.Now.DayOfYear;
textblock1.Text = bible[index];
AddBibleInYear2();
int index = DateTime.Now.DayOfYear;
textblock2.Text = bible[index];
// Sample code to localize the ApplicationBar
//BuildLocalizedApplicationBar();