Part 17: Introducing the Coding4Fun Toolkit

Play Part 17: Introducing the Coding4Fun Toolkit
Sign in to queue

Description

Source Code: https://aka.ms/absbeginnerdevwp8
PDF Version: https://aka.ms/absbeginnerdevwp8pdf

Recording a custom sound in our app would be difficult to code by hand. Fortunately, your friends at Coding4Fun, and Clint Rutkas specifically, have created a Toolkit for Windows Phone that hides the complexity behind easy to use programmatic interfaces. If you're not familiar with Coding4Fun, it's a Channel9 site that engages in geeky cool projects, not your standard business apps ... they usually use hardware like the Kinect as the interface for controlling things such as boxing robots and even a Ford Mustang that was heavily modified with Microsoft technology ... just to prove that it could be done.

https://channel9.msdn.com/coding4fun

Clint is usually in the center of these projects and he is the author and curator of the Coding4Fun Toolkit.

By using this package in our project, we get some additional tools we can utilize in our apps such as a little "About This App" message box (the AboutPrompt) suited for Windows Phone development. In this lesson, I'll demonstrate how to install the Coding4Fun Toolkit package into our app using NuGet. Once we install it, we'll use it to implement the AboutPrompt.

In this short lesson, our game plan is to:

  1. Use NuGet to install the Coding4Fun Toolkit package into our solution.
  2. Snoop around and see what it added.
  3. Add an AboutPrompt to our app.

Update to series: Being sure we have the newest version of NuGet.

With a fresh install of Visual Studio 2012, we’ll need to update NuGet to get some of the newer packages such as the Coding4Fun Toolkit.  It is a super easy process and can be done in a few clicks.

  1. Go to the Tools Menu –> Extensions and Updates
  2. Go to the Update Tab –> Visual Studio Gallery

    nugetUpdate
  3. Click Update
  4. Restart Visual Studio

1. Install the Coding4Fun Package

There are many ways to get to the NuGet package manager ... this time we'll right-click on the References folder and select "Manage NuGet Packages ...":

Generic Episode Image

 

This will open up the Manage NuGet Packages Dialog:

Generic Episode Image

 

  1. In the Search box, search for: "Coding4Fun".
  2. Click the Install button next to the "Coding4Fun Toolkit - Complete" package ... Clint split up the Coding4Fun toolkit into sub-packages so that developers can just pick and choose the parts they want in their project. However, for simplicity—and because we'll use a few different parts and want to familiarize ourselves with the package, we'll choose to install the Complete version.

After a few moments, you'll see green checkmarks next to the packages that were installed:

Generic Episode Image

 

... and you can click the Close button that in dialog to close it.

Now, in the Solution Explorer, you can see new References that were added:

 

Generic Episode Image

 

... also, a new folder called Toolkit.Content and a ReadMe.Coding4Fun.Toolkit.txt file were added:

 

Generic Episode Image

 

Opening the ReadMe.Coding4Fun.Toolkit.txt file, we can see versioning information (what changed) and migration notes:

 

Generic Episode Image

 

2. Employing the AboutPrompt

We'll take the simple step of adding an AboutPrompt to the app. When the user selects the "About" menu option, we want to display a popup:

 

Generic Episode Image

 

We're missing a using statement, so use the hover-over-the-blue-dash-technique to add the appropriate using statement to the code file:

 

Generic Episode Image

 

Once we've resolved the reference to the AboutPrompt class, we'll call it's Show() method. There are many overloaded versions of this method, but we'll pass in the following information ...

 

Generic Episode Image

 

... which produces the following results:

 

Generic Episode Image

 

It's quick and simple and for this particular app, we probably need nothing more fancy.

Leveraging open source (or even commercial) packages is a great way to add features quickly to your development projects. The whole .NET community on CodePlex is built on sharing packages, components, templates and so on to help each other quickly implement features. You can save yourself a lot of time during your career by spending a few hours exploring the work of others before going off and writing your own. Alternatively, use the search box on the NuGet Package Manager to find similar packages and evaluate the strengths and weaknesses of each one relative to the needs of your project.

 

Recap

To recap, in this lesson we leveraged the Coding4Fun Toolkit to add one small feature now as well as one large feature later in this series. We learned how to add packages to our app using the NuGet Package Manager dialog, how to read the description of the package to learn more, and how packages can be subdivided to minimize unnecessary references and complexity in our projects.

Embed

Download

The Discussion

  • User profile image
    babayev96

    I study secondary school. I'm interested windows phone. I had a problem with Coding4Fun toolkit and after this video i solved it. This is great video. Thanks!

  • User profile image
    BobTabor

    @babayev96: Very cool.  Glad to hear it helped.

  • User profile image
    Gabe P

    I've noticed that in your text walkthrough on certain lessons, the code is different from what is in the video lesson. I'm not sure if that matters, but I was just noting that it has confused me a couple of times going through to find mistakes i've made in my code.

  • User profile image
    BobTabor

    @Gabe P: Yes, I did do that in a few cases.  90% of the time, it's purely cosmetic ... I just split a single line of code into multiple lines.  In some cases, there is a different style of implementation, but hopefully those differences are small and localized to a single area.  I apologize for the confusion.  These were created at two different times and it's almost impossible to keep them in sync.

  • User profile image
    rfreytag

    While following the installation instructions I got the error:

    'Coding4Fun.Toolkit.Audio 2.0.7'. You are trying to install this package into a project that targets 'WindowsPhone,Version=v8.0', but the package does not contain any assembly references that are compatible with that framework. For more information, contact the package author.

    When I tried to install any Coding4Fun nuget package.  Looking on the Coding4Fun website it appears that is due to not having updated nuget to 2.1 or more recent.  Did that and you are good to go.  (However, what I had to do was update VS2012 - that done all was golden for me).

  • User profile image
    Clint

    @rfreytag: yup, we updated the text and PDF to reflect this.

  • User profile image
    gamboasud

    Good day, I want to change the format to include only helps AboutPrompt information from my application, and I can make this change?, Thank you very much

  • User profile image
    Clint

    @gamboasud: yup, it is pretty dynamic and adjustable to suit your needs.  It will grab a few bits like application name and version from your manifest file, rest is up to you to put in.  Because channel 9 did the application with Bob, we opt'ed to use our information on the about prompt screen.

    Here are some of the samples from the tester app at http://coding4fun.codeplex.com   Each will have a slightly different result or you can even customize it more like I did with the Coding4FunAboutPrompt where there is a customized watermark and footer.

     

    private void AboutPromptBlankClick(object sender, RoutedEventArgs e)
    {
        var about = new AboutPrompt();
        about.Completed += PopUpPromptObjectCompleted;
    
        about.Show();
    }
    
    private void AboutPromptBasicClick(object sender, RoutedEventArgs e)
    {
        var about = new AboutPrompt();
        about.Completed += PopUpPromptObjectCompleted;
    
        about.Show("Clint Rutkas", "ClintRutkas", "Clint@Rutkas.com", "http://betterthaneveryone.com");
    }
    
    private void AboutPromptLongClick(object sender, RoutedEventArgs e)
    {
        var about = new AboutPrompt { Title = "Custom Title", VersionNumber = "v3.14159265" };
        about.Completed += PopUpPromptObjectCompleted;
    
        about.Show(
            new AboutPromptItem { Role = "dev", AuthorName = "Clint Rutkas" },
            new AboutPromptItem { Role = "site", WebSiteUrl = "http://coding4fun.com" });
    }

  • User profile image
    Darshan

    Showing this error...

    Attempting to resolve dependency 'Coding4Fun.Toolkit.Audio'.
    Attempting to resolve dependency 'Coding4Fun.Toolkit.Controls'.
    Attempting to resolve dependency 'Coding4Fun.Toolkit.Net'.
    Attempting to resolve dependency 'Coding4Fun.Toolkit.Storage'.
    Successfully installed 'Coding4Fun.Toolkit.Audio 2.0.7'.
    Successfully installed 'Coding4Fun.Toolkit.Controls 2.0.7'.
    Successfully installed 'Coding4Fun.Toolkit.Net 2.0.7'.
    Successfully installed 'Coding4Fun.Toolkit.Storage 2.0.7'.
    Successfully installed 'Coding4Fun.Toolkit.Complete 2.0.7'.
    Successfully uninstalled 'Coding4Fun.Toolkit.Audio 2.0.7'.
    Install failed. Rolling back...
    Could not install package 'Coding4Fun.Toolkit.Audio 2.0.7'. You are trying to install this package into a project that targets 'WindowsPhone,Version=v8.0', but the package does not contain any assembly references that are compatible with that framework. For more information, contact the package author.

  • User profile image
    Clint
    @Darshan: did you update nuget like the text states?
  • User profile image
    dar5han

    @Clint:Thx for your reply. can u  tel me how to update this, b'cz when i'm going to update in nuget its showing "no package update are available".

  • User profile image
    Clint

    @dar5han:  it is in the text right at the start.

    update to series: Being sure we have the newest version of NuGet.

    With a fresh install of Visual Studio 2012, we'll need to update NuGet to get some of the newer packages such as the Coding4Fun Toolkit.  It is a super easy process and can be done in a few clicks.

    1. Go to the Tools Menu –> Extensions and Updates
    2. Go to the Update Tab –> Visual Studio Gallery
      nugetUpdate
    3. Click Update
    4. Restart Visual Studio
  • User profile image
    Sugan

    hi there,

    Am just starting to build windows apps.

    I have found this error on my build

    Error
    1
    'System.Windows.Controls.TextBlock' does not contain a definition for 'Navigate' and no extension method 'Navigate' accepting a first argument of type 'System.Windows.Controls.TextBlock' could be found (are you missing a using directive or an assembly reference?)

    What should I do to fix it ..

    Thanks in advance., :)

  • User profile image
    Clint

    @Sugan: I'm not sure where you're getting this from.  This lesson doesn't include anything about navigation

  • User profile image
    qcihdtm

    Hi,

    I am new to .Net/Phone development and I am not sure that I understood this correctly.

    If I include NuGet packages into my application, is there any license that I would be breaking if I decide to make my application commercially available?

    Thanks!

  • User profile image
    Clint

    @qcihdtm: nuget packages list their licenses before you install them, typical request is you state you are using them in an about page.  Twitter's application is a great example of this.

  • User profile image
    Sugan

    Yes .. This isnt abt this lesson .. But i get this error wen i started building the first simple windows phone app as it was shown in the msdn site
    https://msdn.microsoft.com/en-us/library/windowsphone/develop/ff402526(v=vs.105).aspx

  • User profile image
    Clint

    @Sugan: You didn't list an error.  Also we're trying to keep questions only to the topic of the video at hand

  • User profile image
    kindly276

    @Bob When I updated NuGet and Coding4Fun. But I have 1 Error: microsoft visual studio 2013 has stopped working  .... windows is checking for a solution to the problem Bla Bla. Please Help me! 

  • User profile image
    BobTabor

    @kindly276: Restart Visual Studio?  Reboot your computer? Try again?  If these don't work, try the MSDN Forums.  Sorry!  I just know how it should work ... not why it doesn't.  :(

Add Your 2 Cents