G+_Joe Maruschek Posted September 30, 2014 Share Posted September 30, 2014 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 More sharing options...
G+_Colin Nelson Posted September 30, 2014 Share Posted September 30, 2014 Nice PoC there. I used to be highly skeptical of XAML and shied away from using it in my applications, but I've come around recently. This does a great job of showing just how easy and powerful XAML can be Link to comment Share on other sites More sharing options...
Recommended Posts