1
Mainpage.xaml.cs code

public partial class MainPage : PhoneApplicationPage
{ string f;
// Constructor
public MainPage()
{
InitializeComponent();



WebClient webClient = new WebClient();
webClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(webClient_DownloadStringCompleted);


webClient.DownloadStringAsync(new Uri("http://www.taxmann.com/TaxmannWhatsnewService/mobileservice.aspx?service=topstories"));

}

void webClient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
var rootObject = JsonConvert.DeserializeObject<List<NewsItem>>(e.Result);




foreach (var item in rootObject)
{


// Console.WriteLine(item.news_id + "new_id");
f += '|'+item.news_id;
//f ='|' + item.news_id;




}

lstEmployee.ItemsSource = rootObject;
}




private void lstEmployee_SelectionChanged_1(object sender, SelectionChangedEventArgs e)
{
int selindex = lstEmployee.SelectedIndex;

//ListBox sourceList = sender as ListBox;
//ListBox.se



(Application.Current as App).selectedNewsItem = lstEmployee.Items[lstEmployee.SelectedIndex] as NewsItem;
NavigationService.Navigate(new Uri("/Page1.xaml", UriKind.Relative));



}



}

public class NewsItem
{
public string news_id { get; set; }
public string news_title { get; set; }
public string website_link { get; set; }
public string imagepath { get; set; }
public string news_date { get; set; }

public string image_path { get; set; }
public string news_detail_description { get; set; }

}


}



page1.xaml.cs



public Page1()
{
InitializeComponent();

Loaded += new RoutedEventHandler(Page1_Loaded);


}

void Page1_Loaded(object sender, RoutedEventArgs e)
{
NewsItem selectedNewsItem = (Application.Current as App).selectedNewsItem;
// TextBlockNewsDescription.Text = selectedNewsItem.news_detail_description;
string strURI= selectedNewsItem.news_detail_description;

// strURI.Replace("<link href='http://www.taxmann.com/css/taxmannstyle.css' rel='stylesheet' type='text/css' />", "");
// string k = "<html><body style='background-color:Black;font-size:30px;color:#fff;'>" + strURI + "</body></html>";



string k = "<html><body href='http://www.taxmann.com/css/taxmannstyle.css' rel='stylesheet' type='text/css'>" + strURI + "</body></html>";

webBrowser1.NavigateToString(k);


}




}
}

我想在 page1.xaml 中应用页面翻转我能够在 listview 中的 mainpage.xaml 中显示数据,并且在 page1.xaml.cs 中我根据主页的项目在 web 视图中显示数据现在我想要 page1.xaml 翻转假设用户翻到下一页,然后显示下一个项目详细信息,如果前一页翻页,则应显示上一个新闻详细信息。(就像 android view pager 一样)

我必须在 Windows Phone 7 中创建基于新闻的应用程序,请帮助我

4

2 回答 2

0

您可以将 Pivot 控件添加到 Page1.xaml,将其绑定到 NewsItem 集合并将其设置currentItemselectedNewsItem

于 2013-03-25T07:06:11.070 回答
0

您可以使用全景模板代替原始模板。

于 2013-03-25T06:55:12.123 回答