I found this cool page to display RSS feed items in WPF:
Build an RSS reader in 5 minutes
It works great. I thought I would see how it behaves with dream.in.code's feed:
http://feeds.feedbur...ured?format=xml

Unfortunately it, for me, produces a Script Error dialog several times. My settings in IE are already set to not display this dialog. I suppose we could just press "No", don't run any further scripts, but I investigated further to see if I could disable the dialog.
I found some code that attempts to disable the dialog but for a WebBrowser control. I then found the following link that converts a Frame to a WebBrowser, so that I could then attempt the code to disable the dialog.
WPF WebBrowser Control and the Document Object
Here is the code-behind that attempts the disabling:
Here's the XAML (very similar to that in the original link above):
Well, as you may have guessed by now, the attempt to disable the script dialog doesn't work. Anyway, if you don't mind responding to the dialog, then you could take this and make it look more attractive! Otherwise, if anyone knows how the dialog might be disabled, then I'll be pleased to hear from them. Andy.
PS I suppose it would also be possible to click a title on the left and have the itemcontent (the Summary) appear on the right, but I haven't pursued this.
Build an RSS reader in 5 minutes
It works great. I thought I would see how it behaves with dream.in.code's feed:
http://feeds.feedbur...ured?format=xml

Unfortunately it, for me, produces a Script Error dialog several times. My settings in IE are already set to not display this dialog. I suppose we could just press "No", don't run any further scripts, but I investigated further to see if I could disable the dialog.
I found some code that attempts to disable the dialog but for a WebBrowser control. I then found the following link that converts a Frame to a WebBrowser, so that I could then attempt the code to disable the dialog.
WPF WebBrowser Control and the Document Object
Here is the code-behind that attempts the disabling:
using System; using System.Collections.Generic; using System.Linq; using System.ServiceModel; using System.ServiceModel.Syndication; // add this using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using System.Xml; namespace TestFeedsWPF { /// <summary> /// Interaction logic for Mainwindow.xaml /// </summary> public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); } // http://www.thomaslevesque.com/2009/02/13/build-an-rss-reader-in-5-minutes/ private void btnGo_Click(object sender, RoutedEventArgs e) { using (XmlReader reader = XmlReader.Create(txtUrl.Text)) { SyndicationFeed feed = SyndicationFeed.Load(reader); lstFeedItems.ItemsSource = feed.Items; } } private void frmContents_ContentRendered(object sender, EventArgs e) { // http://www.rhizohm.net/irhetoric/post/2008/11/12/0a-WPF-WebBrowser-Control-and-the-Document-Object0a-.aspx // Add Reference MS HTML Object Library if (frmContents.Content.GetType() == typeof(WebBrowser)) { WebBrowser browser = (WebBrowser)frmContents.Content; mshtml.HTMLDocument dom = (mshtml.HTMLDocument)browser.Document; if (browser == null || browser.Document == null) return; dynamic document = browser.Document; //if (document.readyState != "complete") // is this needed? // return; dynamic script = document.createElement("script"); script.type = @"text/javascript"; script.text = @"window.onerror = function(msg,url,line){return true;}"; document.head.appendChild(script); } } } }
Here's the XAML (very similar to that in the original link above):
<Window x:Class="TestFeedsWPF.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="RSS Feed Reader" Height="400" Width="600"> <Grid> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition Height="*"/> </Grid.RowDefinitions> <DockPanel Grid.Row="0"> <Button Name="btnGo" DockPanel.Dock="Right" Width="50" Content="Go" Click="btnGo_Click" /> <TextBox Name="txtUrl" Text="Address here" /> <!--http://feeds.feedburner.com/dic_featured?format=xml--> </DockPanel> <Grid Grid.Row="1"> <Grid.ColumnDefinitions> <ColumnDefinition Width="250"/> <ColumnDefinition Width="Auto"/> <ColumnDefinition Width="*"/> </Grid.ColumnDefinitions> <ListBox Name="lstFeedItems" Grid.Column="0" DisplayMemberPath="Title.Text" /> <GridSplitter Grid.Column="1" VerticalAlignment="Stretch" Width="3" Resizebehavior="PreviousAndNext" ResizeDirection="Columns"/> <Frame Name="frmContents" Source="{Binding SelectedItem.Links[0].Uri, ElementName=lstFeedItems}" Grid.Column="2" ContentRendered="frmContents_ContentRendered" NavigationUIVisibility="Visible"> </Frame> </Grid> </Grid> </Window>
Well, as you may have guessed by now, the attempt to disable the script dialog doesn't work. Anyway, if you don't mind responding to the dialog, then you could take this and make it look more attractive! Otherwise, if anyone knows how the dialog might be disabled, then I'll be pleased to hear from them. Andy.
PS I suppose it would also be possible to click a title on the left and have the itemcontent (the Summary) appear on the right, but I haven't pursued this.
1 Comments On This Entry
Page 1 of 1
Page 1 of 1
Trackbacks for this entry [ Trackback URL ]
← January 2021 →
S | M | T | W | T | F | S |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
31 |
Tags
My Blog Links
Recent Entries
Recent Comments
Search My Blog
2 user(s) viewing
2 Guests
0 member(s)
0 anonymous member(s)
0 member(s)
0 anonymous member(s)