Building a Metro App Part 2: Listing 1

Implementing the Share Source Contract

void MainPage_DataRequested(DataTransferManager sender, DataRequestedEventArgs args)  
{  
   // have a selected RSS feed item?      
   if (FeedListView.SelectedItem != null)      
   {          
    RSSItem selectedItem = FeedListView.SelectedItem as RSSItem;               
   args.Request.Data.Properties.Title = selectedItem.Title;          
   args.Request.Data.Properties.Description = selectedItem.Description;          
   args.Request.Data.SetText(selectedItem.Description);          
   args.Request.Data.SetHtml(selectedItem.Description);
    if (selectedItem.Links.Count > 0)          
    {
    args.Request.Data.SetUri(selectedItem.Links[0].Link);
    }
    }
    else if(!String.IsNullOrWhiteSpace(FeedUrl.Text))
    {
    // share the loaded Feed URL          
    args.Request.Data.Properties.Title = FeedTitle.Text;          
    args.Request.Data.Properties.Description = "An RSS feed link from Daily Reader.";          
    args.Request.Data.SetUri(new Uri(FeedUrl.Text));      
  }  
}

About the Author

Eric Vogel is a Senior Software Developer for Red Cedar Solutions Group in Okemos, Michigan. He is the president of the Greater Lansing User Group for .NET. Eric enjoys learning about software architecture and craftsmanship, and is always looking for ways to create more robust and testable applications. Contact him at [email protected].

comments powered by Disqus

Featured

  • Black White Wave IMage

    New Azure AI VMs Immediately Claim Top500 Supercomputer Rankings

    Visual Studio coders who dabble in artificial intelligence projects can now take advantage of new Azure virtual machines (VMs) featuring 80 GB NVIDIA GPUs that immediately claimed four spots on the TOP500 supercomputers list, Microsoft said.

  • Colorful Night IMage

    Auto Completions Speed Up in Java on Visual Studio Code

    Java jockeys using Microsoft's Visual Studio Code editor will see faster code completions thanks to a new language server.

  • New Toolkit for Writing Visual Studio Extensions (And Where to Find Extensions)

    Microsoft details a new Extensibility Essentials toolkit for VS 2022 and explains where to find your favorite tools.

  • New TypeScript 4.5 Improves Asynchronous Programming

    TypeScript 4.5 has shipped with a new Awaited type and Promise improvements for enhancing asynchronous programming in Microsoft's popular take on JavaScript that adds statically checked types.

Upcoming Events