Data Binding in Windows Presentation Foundation
- Posted: Sep 06, 2005 at 5:07 PM
- 54,225 Views
- 11 Comments
Download
How do I download the videos?
- To download, right click the file type you would like and pick “Save target as…” or “Save link as…”
Why should I download videos from Channel9?
- It's an easy way to save the videos you like locally.
- You can save the videos in order to watch them offline.
- If all you want is to hear the audio, you can download the MP3!
Which version should I choose?
- If you want to view the video on your PC, Xbox or Media Center, download the High Quality WMV file (this is the highest quality version we have available).
- If you'd like a lower bitrate version, to reduce the download time or cost, then choose the Medium Quality WMV file.
- If you have a Zune, WP7, iPhone, iPad, or iPod device, choose the low or medium MP4 file.
- If you just want to hear the audio of the video, choose the MP3 file.
Right click “Save as…”
- Mid Quality WMV (Lo-band, Mobile)
Comments Closed
Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation,
please create a new thread in our Forums,
or
Contact Us and let us know.
Follow the Discussion
Tim sets the DataContext on the DockPanel to be a binding to the items in the RSS feed.
Then the nested ListBox doesn't need to say anything except to Bind. It gets its data from its parent DataContext.
I just tested it out and it seemed to be fine. Try going directly to the URL for the WMV:
http://channel9.msdn.com/Screencasts/DataBindinginWPF.wmv
Best wishes,
Tim
Here's the source code, based on the Sept CTP bits:
<StackPanel xmlns="http://schemas.microsoft.com/winfx/avalon/2005" xmlns:x="http://schemas.microsoft.com/winfx/xaml/2005" Margin="10">
<StackPanel.Resources>
<XmlDataSource x:Key="Blog" Source="http://blogs.msdn.com/tims/rss.aspx"/>
<DataTemplate x:Key="TitleTemplate">
<TextBlock TextContent="{Binding XPath=title}"/>
</DataTemplate>
</StackPanel.Resources>
<Label Content="{Binding Source={StaticResource Blog}, XPath=/rss/channel/title}" FontSize="24" FontWeight="Bold" />
<Label Content="{Binding Source={StaticResource Blog}, XPath=/rss/channel/description}" FontSize="18" />
<DockPanel DataContext="{Binding Source={StaticResource Blog}, XPath=/rss/channel/item}" >
<ListBox DockPanel.Dock="Left" ItemsSource="{Binding}" ItemTemplate="{StaticResource TitleTemplate}" IsSynchronizedWithCurrentItem="True" />
<TextBox Name="Contents" Text="{Binding XPath=description}" Wrap="True" Width="Auto" />
</DockPanel>
</StackPanel>
Tim,
After attending the PDC, I've installed the Sept CTP bits. I've copied your sample (above) and it doesn't work in XAMLPAD. Am I missing something?
Here's a couple keywords that its "upset" about:
XmlDataSource --> changed to XmlDataProvider
Wrap --> removed as it just won't work.
Then another quick question... What code could I add to this sample to automatically get new RSS content and have the lists automatically update? I was trying to do things declartively... I was trying to set the source of the XmlDataProvider to be bound to a TextBox. But to no avail. Do I need to revert to code behind?
Joe
We've experienced some pain trying to make the various demos we saw at PDC05 and on various tech evang blogs work on the PDC05 "The Goods" bits because of changes to the class libs/schemas since the WinFX Beta was released. With some effort it has been possible to figure out the changes and/or find updated demos.
However, it would be helpful if the various tech evangelists were to post updated demos that work on the PDC05 bits.
Thanks!
Erik
TextWrapping="Wrap"
And for TextContent="..." just use Text="..."
If only we didnt need to compile for events, roll on wpf/e
I got it to work with the Feb CTP. See updated code below:
<StackPanel xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Margin="10">
<StackPanel.Resources>
<XmlDataProvider x:Key="Blog" Source="http://blogs.msdn.com/tims/rss.aspx"/>
<Label Content="{Binding Source={StaticResource Blog}, XPath=/rss/channel/title}" FontSize="24" FontWeight="Bold" />
<Label Content="{Binding Source={StaticResource Blog}, XPath=/rss/channel/description}" FontSize="18" />
<DockPanel DataContext="{Binding Source={StaticResource Blog}, XPath=/rss/channel/item}" ><ListBox DockPanel.Dock="Left" ItemsSource="{Binding}" ItemTemplate="{StaticResource TitleTemplate}" IsSynchronizedWithCurrentItem="True" />
<TextBox Name="Contents" Text="{Binding XPath=description}" TextWrapping="Wrap" Width="Auto" />
</DockPanel>
</StackPanel>
Remove this comment
Remove this thread
close