.


:




:

































 

 

 

 





HTTP RSS

 

RSS, , RSS . RSS , RSS MSDN: http://blogs.msdn.com/b/rudevnews/rss.aspx

 

, Windows Phone Application SimpleRussianRSSReader.

 

, .

 

URL, RSS:

 

const string RSS = "http://blogs.msdn.com/b/rudevnews/rss.aspx";

 

.

 

API: WebClient HttpWebRequest. WebClient API GET/POST , HttpWebRequest PUT/DELETE . , WebClient.

 

, , :

private void LoadRSS()

{

WebClient client = new WebClient();

client.DownloadStringCompleted +=

new DownloadStringCompletedEventHandler

(client_DownloadStringCompleted);

client.DownloadStringAsync(new Uri(RSS));

}

 

:

string RSSString = "";

 

, , :

void client_DownloadStringCompleted

(object sender, DownloadStringCompletedEventArgs e)

{

if (e.Error == null)

{

RSSString = e.Result;

}

}

 

, TextBlock , , XAML :

<!--TitlePanel contains the name of the application and page title-->

<StackPanel x:Name="TitlePanel"

Grid.Row="0" Margin="12,17,0,28">

<TextBlock x:Name="ApplicationTitle"

Text=" MSDN" Style="{StaticResource PhoneTextNormalStyle}"/>

<TextBlock x:Name="PageTitle"

Text="" Margin="9,-7,0,0"

Style="{StaticResource PhoneTextTitle1Style}"/>

</StackPanel>

 

<!--ContentPanel - place additional content here-->

<Grid x:Name="ContentPanel" Grid.Row="1"

Margin="12,0,12,0">

<TextBlock Name="RSSText" ></TextBlock>

</Grid>

 

LoadRSS, , Text RSSText .

 

(F5) , .

 

 

HTTP. , HttpWebRequest , callback .

 

.

 

TextBlok ListBox .

<!--ContentPanel - place additional content here-->

<Grid x:Name="ContentPanel" Grid.Row="1"

Margin="12,0,12,0">

<ListBox Name="RssList">

<ListBox.ItemTemplate>

<DataTemplate>

<StackPanel>

<TextBlock Text="{Binding pubDate}" FontSize="20"

Foreground="Coral"/>

<TextBlock Text="{Binding title}" TextWrapping="Wrap"

FontSize="22"/>

</StackPanel>

</DataTemplate>

</ListBox.ItemTemplate>

</ListBox>

</Grid>

 

, pubDate title. LINQ XML.

 

PostMessage pubDate title :

public class PostMessage

{

public string pubDate { get; set; }

 

public string title { get; set; }

}

 

System.Xml.Linq using MainPage.xaml.cs

using System.Xml.Linq;

 

, ListBox, .

XElement twitterElements = XElement.Parse(e.Result);

var postList =

from tweet in twitterElements.Descendants("item")

select new PostMessage

{

title = tweet.Element("title").Value,

pubDate = tweet.Element("pubDate").Value

};

 

RssList.ItemsSource = postList;

 

(F5) , RSS.

 

 

, . , , RSS .

 

, , .

 

PostMessage link:

public class PostMessage

{

public string pubDate { get; set; }

 

public string title { get; set; }

 

public string link { get; set; }

}

 

RSS :

var postList =

from tweet in twitterElements.Descendants("item")

select new PostMessage

{

title = tweet.Element("title").Value,

pubDate = tweet.Element("pubDate").Value,

link = tweet.Element("link").Value

};

 

XAML MainPage SelectionChanged :

private void RssList_SelectionChanged

(object sender, SelectionChangedEventArgs e)

{

WebBrowserTask webTask = new WebBrowserTask();

webTask.Uri = new Uri(((PostMessage)(RssList.SelectedItem)).link);

webTask.Show();

}

 

using :

using Microsoft.Phone.Tasks;

 

(F5) , .

 

Windows Phone :

: /, IsolatedStorageSettings;

IsolatedStorageFile;

LINQ SQL.

 

, - .

 

, , .





:


: 2017-02-24; !; : 244 |


:

:

, .
==> ...

1343 - | 1262 -


© 2015-2024 lektsii.org - -

: 0.027 .