-1
我有5個按鈕,它們通過顯示忽略星期六和星期日的星期幾名稱來動態更改。我可以使用Button.Content
在Windows Phone中實現此目的嗎?Windows Phone App 7.1更改後面代碼的按鈕文本
現在我嘗試運行它,但是當我想要轉到包含這些按鈕的屏幕時,它不會加載但凍結並且不會輸出。
我在想什麼或做錯了什麼?
這裏是我的代碼:
DateTime datetoday = DateTime.Today;
for (int i = 0; i < 5;)
{
if (datetoday.DayOfWeek == DayOfWeek.Sunday || datetoday.DayOfWeek == DayOfWeek.Saturday)
{
//it's saturday of sunday
}
else
{
if (i == 0)
{
if (datetoday.DayOfWeek == DayOfWeek.Friday)
{
firstButton.Content = "Vrijdag";
}
if (datetoday.DayOfWeek == DayOfWeek.Thursday)
{
firstButton.Content = "Donderdag";
}
if (datetoday.DayOfWeek == DayOfWeek.Wednesday)
{
firstButton.Content = "Woensdag";
}
if (datetoday.DayOfWeek == DayOfWeek.Tuesday)
{
firstButton.Content = "Dinsdag";
}
if (datetoday.DayOfWeek == DayOfWeek.Monday)
{
firstButton.Content = "Maandag";
}
}
if (i == 1)
{
if (datetoday.DayOfWeek == DayOfWeek.Friday)
{
secondButton.Content = "Vrijdag";
}
if (datetoday.DayOfWeek == DayOfWeek.Thursday)
{
secondButton.Content = "Donderdag";
}
if (datetoday.DayOfWeek == DayOfWeek.Wednesday)
{
secondButton.Content = "Woensdag";
}
if (datetoday.DayOfWeek == DayOfWeek.Tuesday)
{
secondButton.Content = "Dinsdag";
}
if (datetoday.DayOfWeek == DayOfWeek.Monday)
{
secondButton.Content = "Maandag";
}
}
if (i == 2)
{
if (datetoday.DayOfWeek == DayOfWeek.Friday)
{
thirdButton.Content = "Vrijdag";
}
if (datetoday.DayOfWeek == DayOfWeek.Thursday)
{
thirdButton.Content = "Donderdag";
}
if (datetoday.DayOfWeek == DayOfWeek.Wednesday)
{
thirdButton.Content = "Woensdag";
}
if (datetoday.DayOfWeek == DayOfWeek.Tuesday)
{
thirdButton.Content = "Dinsdag";
}
if (datetoday.DayOfWeek == DayOfWeek.Monday)
{
thirdButton.Content = "Maandag";
}
}
if (i == 3)
{
if (datetoday.DayOfWeek == DayOfWeek.Friday)
{
fourthButton.Content = "Vrijdag";
}
if (datetoday.DayOfWeek == DayOfWeek.Thursday)
{
fourthButton.Content = "Donderdag";
}
if (datetoday.DayOfWeek == DayOfWeek.Wednesday)
{
fourthButton.Content = "Woensdag";
}
if (datetoday.DayOfWeek == DayOfWeek.Tuesday)
{
fourthButton.Content = "Dinsdag";
}
if (datetoday.DayOfWeek == DayOfWeek.Monday)
{
fourthButton.Content = "Maandag";
}
}
if (i == 4)
{
if (datetoday.DayOfWeek == DayOfWeek.Friday)
{
fifthButton.Content = "Vrijdag";
}
if (datetoday.DayOfWeek == DayOfWeek.Thursday)
{
fifthButton.Content = "Donderdag";
}
if (datetoday.DayOfWeek == DayOfWeek.Wednesday)
{
fifthButton.Content = "Woensdag";
}
if (datetoday.DayOfWeek == DayOfWeek.Tuesday)
{
fifthButton.Content = "Dinsdag";
}
if (datetoday.DayOfWeek == DayOfWeek.Monday)
{
fifthButton.Content = "Maandag";
}
}
//currentWeek[i] = datetoday;
// i++;
}
// datetoday = datetoday.AddDays(1);
}
}
}
}
BRB,thedailywtf.com – Will 2014-10-29 14:20:03