Jump to content

With the show taking a more advanced look at C#, I 'm taking the opportunity to learn more about...


G+_Joe Maruschek
 Share

Recommended Posts

XAMLOnlyPodcastViewer-2.png

With the show taking a more advanced look at C#, I'm taking the opportunity to learn more about WPF and XAML.  I found this example in a book, and I thought it was so cool: a XAML-only Podcast Viewer.  You can download the whole project here: http://joemaruschek.com/test/XamlOnlyRSS.zip

I know we are talking about C# right now, but what is surprising is this program doesn't use any C# code at all except the required call to InitializeComponent().  The program started life as an RSS reader, but I was able to easily change it to play video podcasts.  In fact, there is not much to the XAML either.  Check out the MainWindow.xaml file in my github: https://github.com/joemarus/csharp_part2_examples/blob/master/MainWindow.xaml.  You can make your own version from scratch by just starting a new WPF application called "XamlOnlyRSS", and then replace the contents of your MainWindow.xaml file with the one from github.

So how does this XAML-only program accomplish so much?  It uses the power of WPF's Data Binding feature to bind directly to different pieces of an XML file.  In this case, the XML file is the podcast RSS feed.  WPF provides a handy class called XmlDataProvider that wraps the XML file and does all the hard work of making the data available to Data Binding-aware controls.  

Besides all the Data Binding stuff, we also see another example of laying out your controls on a window with another type of panel: the DockPanel.  I hope you find this little example of XAML as interesting as I did!

Link to comment
Share on other sites

 Share

×
×
  • Create New...