(X) Hide this
    • Login
    • Join
      • Generate New Image
        By clicking 'Register' you accept the terms of use .

Forums

Search in:

Go

RSS link

  • Lynx101
    Lynx101
    0 points
    0 posts
    Jul 19, 2012, 12:32 AM
        Report Abuse

    Hi, new to the windows phone development and wondered if anyone could help. I have an RSS feed working fine, but I don't know who to link to the link webpage. Here is my part of the code if anyone can assist me:

    Mainpage.xaml

    <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0"/>
            <Grid Margin="0,170,0,37" Grid.RowSpan="2">
                <ListBox ItemsSource="{Binding Items}" Height="auto" Margin="0,6,0,0" x:Name="listBox1" VerticalAlignment="Top" HorizontalAlignment="Center" Width="450">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Vertical">
                                <Button HorizontalAlignment="Left">
                                    <Button.Content>
                                    <Image Source="{Binding Image}" Margin="-10,0,0,0" HorizontalAlignment="Left" Width="400" Height="200" />
                                    </Button.Content>
                                </Button>

                                <StackPanel Width="auto" Margin="0,10,0,10" Orientation="Vertical">
                                <TextBlock Text="{Binding Title}" FontSize="26.667" TextWrapping="Wrap" Style="{StaticResource PhoneTextAccentStyle}" DataContext="{Binding}" Foreground="Black" Margin="12,-60,12,0" FontFamily="Calibri" Padding="10,0" VerticalAlignment="Top"/>
                                <TextBlock Text="{Binding Date}" FontSize="18" TextWrapping="Wrap" Style="{StaticResource PhoneTextAccentStyle}" DataContext="{Binding}" Foreground="#FF3A44DC" Margin="12,-23,12,0" FontFamily="Calibri" Padding="10,0" VerticalAlignment="Top"/>
                                <TextBlock Text="{Binding Description}" FontSize="18" TextWrapping="Wrap" Style="{StaticResource PhoneTextAccentStyle}" DataContext="{Binding}" Foreground="Black" Margin="12,0,12,0" FontFamily="Calibri" Padding="10,0"/>

     

                                </StackPanel>
                        </StackPanel>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>

    MainPage.xaml.cs

    public partial class MainPage : PhoneApplicationPage
        {

            // Constructor
            public MainPage()
            {
                InitializeComponent();

                this.Loaded += new RoutedEventHandler(MainPage_Loaded);
            }

            void MainPage_Loaded(object sender, RoutedEventArgs e)
            {
                WebClient wc = new WebClient();
                wc.DownloadStringAsync(new Uri("http://www.templatedepot.co.uk/rss/rss.xml"));
                wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wc_DownloadStringCompleted);

            }

            void wc_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
            {
                if (e.Error != null) return;

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

                listBox1.ItemsSource = from x in xmlItems.Descendants("item")
                                       select new RSSitem
                                       {

                                           Date = x.Element("pubDate").Value,
                                           Link = x.Element("link").Value,
                                           Title = x.Element("title").Value,
                                           Description = x.Element("description").Value,
                                           Image = x.Element("enclosure").LastAttribute.Value

                                       };
                        }
           }

     

        public class RSSitem
        {
            public string Title { get; set; }
            public string Date { get; set; }
            public string Description { get; set; }
            public string Link { get; set; }
            public string Image { get; set; }

     

        }

     Would really appreciate any assistance - Thank you.

     

    Reply
There are no posts in this thread.

    To reply to this thread you must Log In to your account


    Thread


    Tags: 
    • Asked
      633 days ago
    • Viewed
      195
    • Last Activity
      633 days ago

    Related Threads


    Shortcuts