2016-03-02 31 views
0

我在我的應用程序366的html頁面,每個頁面的HTML頁面,在一年中的一天,我會想在本地查看我的應用程序下面的代碼只能查看單個html頁面,但我想要的是根據webview中每月的日期顯示不同的html頁面,即如果用戶在2/3/2016上打開應用程序,應用程序應該打開devotion62.html這是今年的第62天 這是低於 我的代碼XAML如何按照日期和月份的時候在Windows網頁視圖顯示不同的HTML網頁的手機8:

<!--ContentPanel - place additional content here--> 
     <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0"> 
      <phone:WebBrowser HorizontalAlignment="Left" Margin="20,50,0,0" Name="webBrowser1" VerticalAlignment="Top" Height="500" Width="430" /> 
     </Grid> 

XAML.CS

public partial class MainPage : PhoneApplicationPage 
    { 
     private List<string> htmls; 

     private int CurrentIndex = 0; 

     private int TotalCount = 0; 
     // Constructor 
     public MainPage() 
     { 
      InitializeComponent(); 

      // Sample code to localize the ApplicationBar 
      //BuildLocalizedApplicationBar(); 

      this.Loaded += MainPage_Loaded; 
     } 

     private void MainPage_Loaded(object sender, RoutedEventArgs e) 
     { 
      htmls = new List<string>() { "/Bible/devotion60.html", "/Bible/devotion61.html", "/Bible/devotion62.html", "/Bible/devotion63.html" };//List of string will contain all the 366 html files path 
      TotalCount = htmls.Count; 
      if (TotalCount != 0) 

      { 
       webBrowser1.Navigate(new Uri(htmls[CurrentIndex], UriKind.Relative)); 
      } 

     } 

     private void Previous_Click(object sender, EventArgs e) 
     { 
      if (CurrentIndex != 0) 
      { 
       CurrentIndex--; 
      } 

      webBrowser1.Navigate(new Uri(htmls[CurrentIndex], UriKind.Relative)); 
     } 

     private void Next_Click(object sender, EventArgs e) 
     { 
      if (CurrentIndex != TotalCount - 1) 
      { 
       CurrentIndex++; 
      } 

      webBrowser1.Navigate(new Uri(htmls[CurrentIndex], UriKind.Relative)); 
     } 
+0

所以你有什麼問題? –

+0

面臨的挑戰是如何編寫代碼來顯示html頁面根據每月的一天,我已經嘗試寫它,但沒有得到正面的方式 – joakins

回答

0

在你MainPage_Loaded方法添加以下代碼。

CurrentIndex = DateTime.Now.DayOfYear; 
+0

Chirag Shah謝謝 – joakins