.Net Development & General Tech Related News

Bing Silverlight Control with the Bing Web Service Application

May 19th, 2010 Posted in .Net, C#, Silverlight | 2 Comments »

After reading Carl Dickinson’s post on Mando Group Labs about the Bing Silverlight Control, I wanted to give it a try myself.

I decided to set about using the Bing Silverlight control to display available hotels from LateRooms.com.  LateRooms.com have an affiliate scheme that exposes the availability of hotels via XML feeds (you do need an affiliate ID to use the feeds but this could easily be replaced by any other similar feed).

You can view the sample app I have created here (note: LateRooms has mostly UK hotels so probably best trying a UK location, e.g. “Southport UK”). 

To create the app I create added four controls to my page;  

  • Bing Silverlight Control – This is obviously the main focus of the app.
  • A text box and a button to accept a location from the user and start the request to get the hotels.
  • A list box to display a picture, the name and the first line of the address for each of the hotels.

Once the user enters a location into the text box and clicks the button the following happens;

  • The location entered by the user is sent to the Bing Geocode web service and providing it can find a match it returns the lattitude and longitude for the location.
  • This map is then centred on this location.
  • Finally the newly returned coordinates are used to get a list of available hotels from the LateRooms XML feed. This list is then iterated through and a pin for each hotel is added to the map and the list is then bound to the list box.

Finally I added an event handler to the selection changed event of the list box to re-centre the map on the coordinates of the selected hotel.

There is plently more that could be done with this app, not least making the UI a little more attractive, but I wanted to just get a feel of how easy it was to implement some basic Bing maps functionality in Silverlight.

If you are interested to see the source code to the application let me know and I can post it.  Right now I am off to try some more experiments!

Don’t forget if you liked this, subscribe to my RSS feed and / or follow my Twitter (links at the top of the page).

Share this Post:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DotNetKicks
  • Reddit
  • StumbleUpon
  • TwitThis

Technorati Tags: ,

Tags: ,

The Silverlight Masterclass!

April 29th, 2010 Posted in .Net, Silverlight | 1 Comment »

The Silverlight Tour comes to the UK – and it’s called the Masterclass!

This 3 day hands-on training with both designer and developer tracks looks awesome and (uniquely) has two expert trainers per course. 

Currently scheduled in London, Manchester, and the Midlands for June, all courses also come with the chance to win an xbox 360, and Silverlight Spy licences!

Early bird discount of £100 if you book in May, and if you are a member of #SLUGUK or #nxtgenug there are additional discounts to be had.

Full Details are here: http://silverlightmasterclass.net

In addition bbits are holding a raffle for a free ticket for the masterclass. To be eligible to win the ticket (worth £1095!) you MUST paste this text, including all links, into your blog and email Ian@bbits.co.uk with the url to the blog entry.  The draw will be made on June 1st and the winner informed by email and on http://silverlightmasterclass.net

Share this Post:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DotNetKicks
  • Reddit
  • StumbleUpon
  • TwitThis

Technorati Tags: ,

Tags: ,

Silverlight and Windows Phone 7 Link Post

April 8th, 2010 Posted in Silverlight, Windows Phone 7 | No Comments »

With the recent announcements regarding Silverlight 4 and Windows Phone 7 Development, I thought I would share a few links to some sites I have found useful, both recently and in the past when starting to work with Silverlight and Windows Phone 7 dev using Silverlight.

Windows Phone 7 Dev

WP7 Panorama App  Â
http://blogs.claritycon.com/blogs/design/archive/2010/03/30/building-the-elusive-windows-phone-panorama-control.aspx

Twitter App Receiving Push Notifications on WP7   Â
http://skeevs.com/blog/?p=35

Push Notifications Types and a Tutorial Â
http://blogs.claritycon.com/blogs/design/archive/2010/03/30/building-the-elusive-windows-phone-panorama-control.aspx

Building a Flickr AppÂ
http://skeevs.com/blog/?p=4&cpage=1#comment-16

Bing Location Programming on WP7 Â
http://www.earthware.co.uk/blog/index.php/2010/03/writing-a-bing-maps-location-aware-application-for-windows-phone-7-series/

Windows Phone 7 Icon Pack  Â
http://www.sevenforums.com/news/74137-windows-phone-7-series-icon-pack.html 


General Silverlight

Silverlight 4 – A guide to the new features Â
http://timheuer.com/blog/archive/2009/11/18/whats-new-in-silverlight-4-complete-guide-new-features.aspx

Getting Started with Silverlight and Blend   Â
http://refcardz.dzone.com/refcardz/getting-started-silverlight?oid=hom20371

Silverlight UI ControlsÂ
http://www.silverlight.net/learn/tutorials/controls-cs

Silverlight Data Binding Â
http://www.silverlight.net/learn/tutorials/databinding-cs/

Visual State Manager  Â
http://www.silverlight.net/learn/tutorials/stylestemplatesvsm-cs/

Intro to BehaivoursÂ
http://www.kirupa.com/blend_silverlight/introduction_behaviors_pg1.htm

Share this Post:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DotNetKicks
  • Reddit
  • StumbleUpon
  • TwitThis

Technorati Tags: , ,

Tags: , ,

Multi-Select List Box in ASP.NET MVC

February 26th, 2010 Posted in .Net, ASP.NET MVC, ASP.Net, C#, Entity Fraemwork | 1 Comment »

Recently I have been working on an MVC site using the Entity Framework. 

I have some related entities in my EF model, as show below in the form of “Reader” and “Category”, and the relationship between them, i.e. many to many.

When it came to proucing a view and action to perofrm the Create Reader action, I was somewhat puzzled as to how I could allow the user to select one or more categories for a reader. 

I started by having a view model that contained a list of all possible categories and then looping around these in my view and writing a check box out for each one.  When the form was submitted I looked through the form collection to find if any of the category check boxes had been selected.  I didn’t like this one bit and so I set out to find a cleaner way of carrying it out.

After some (quite a lot actually) searching, I stumbled accross the MultiSelectList type, which I could use in my ViewModel and then allow the default model binding to step in and do the leg work for me :) Great!

So, I created a view model, a simplified version of which you can see below;

    public class ReaderCreateViewModel : CustomViewModelBase
    {

        public ReaderCreateViewModel()
        {
            ReaderDetails = new Reader();
            CategoriesList = GetCategories(null);
        }

        public Reader ReaderDetails { get; set; }
        public MultiSelectList CategoriesList { get; private set; }
        public int[] SelectedCategories { get; set; }

        public MultiSelectList GetCategories(int[] selectedValues)
        {
            var te = new myEntities();
            List<Category> categories = te.Categories.ToList();
            return new MultiSelectList(categories, “id”, “Name”, selectedValues);
        }
    }

 As you can see from the code above, the view model contains my Reader entity, a list of type MultiSelectList, which is a list of available categories and an array of integers which represent the Id of any selected Categories.

Then to add a listbox to my view that will bind the MultiSelectList, I simply insert the following into my view.

            <p>
             <label for=”SelectedCategories”>Categories:</label>
        <%= Html.ListBox(“SelectedCategories”, Model.CategoriesList) %>
            </p>

Finally in my controller, I can simply check the SelectedItems object in my model for any selected Ids and add them to the Reader Categories list like this;

            if (model.SelectedCategories != null)
            {
                foreach (var selectedCat in model.SelectedCategories)
                {
                    int selectedCatId = selectedCat;
                    Category category = DataContext.Categories.Where(c => c.id                  == selectedCatId).FirstOrDefault();
                    reader.Categories.Add(category);
                }
            }

And that’s it.  Now there is probably a much better way of doing all or some of the above, but this worked perfectly for me when I needed it, so I hope it helps someone else out as well.  The final multi-select list box looked something like this;

Share this Post:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DotNetKicks
  • Reddit
  • StumbleUpon
  • TwitThis

Technorati Tags: , ,

Tags: , ,

ASP.NET MVC – Passing ViewData to a MasterPage

January 12th, 2010 Posted in .Net, ASP.NET MVC, ASP.Net, C# | No Comments »

If like me you are using ASP.NET MVC for some of your web applications these days and use MasterPages within them, then you may have come accross the need to pass ViewData to the MasterPage.  For example, this might be for a dynamically generated navigation bar.

When I first started using MVC, I simply passed the ViewData required for the MasterPage along with every action, but even with a small site, this was a lot of code replication.

To solve this problem, we can create an ApplicationController class which inherits from the Controller class we all know and love.  Your applications’ controllers then in turn simply inherit from this new ApplicationController.

Below is a simple example of an ApplicationController.

namespace MvcSite.Controllers
{
    public abstract class ApplicationController : Controller
    {
        private MyEntities _dataContext = new MyEntities();

        public MyEntities DataContext
        {
            get { return _dataContext; }
        }

        public ApplicationController()
        {
            ViewData["categories"] = DataContext.Categories.ToList();
        }

    }
}

Hope this helps someone else as well. Certainly removed a headache for me!

Share this Post:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DotNetKicks
  • Reddit
  • StumbleUpon
  • TwitThis

Technorati Tags:

Tags:

3 mobile broadband not working (“No Network”) on Windows 7…

October 26th, 2009 Posted in Windows 7 | 5 Comments »

Well, we moved into our new house this weekend….so I am pretty tired.  I cannot believe how much stuff we have managed to accumulate over a relatively short period of time!  So, now we are living in our very own building site. :)   The front room is currently made up of some scaffolding, two garden chairs and a TV (with Sky HD which got installed this morning…..got to get the priorities right people).

Because of the move, I currently dont have a landline and consequently, there is no broadband! I didn’t this that this would be a problem because I have borrowed a mobile broadband USB dongle from 3……not a problem that is until I plugged it in! 

Once I had plugged in the USB modem and installed the software, I simply got the message “No Network”, but the light on the device was green??  After several more tries of re-installing the device drivers and a few more ideas I decided to visit a friend a use their wi-fi to look for a solution. 

Turns out that if you want to use your 3mobile broadband device on windows 7, you need to download drivers BEFORE you upgrade!  Alternativly, if you are like me and are on Windows 7 already, you too can find a friend with an internet connection and download the updated Windows 7 Only drivers from Three here.

Share this Post:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DotNetKicks
  • Reddit
  • StumbleUpon
  • TwitThis

Technorati Tags: , , ,

Tags: , , ,

Visual Studio 2010 and .Net 4.0 Beta 2 Download Available

October 20th, 2009 Posted in .Net, ASP.NET MVC, ASP.Net, Betas, C#, Entity Framework, Silverlight, microsoft, msdn, visual studio | 1 Comment »

Visual Studio 2010 and .Net 4.0 Beta 2 has now been released to members of MSDN, with a public download available from Wednesday.

Beta 2 brings many improvements to the table, including improvements in Sharepoint, WPF, ASP.NET, WinForms, as well as improvements to the core IDE and testing tools. I saw some of these IDE improvements at an event with Scott Gu in Manchester a couple of weeks ago and they look pretty cool.

Visual Studio now comes in several flavours, namely Premium, Professional and Ultimate and the good news is that TFS 2010 comes out of the box with all three.  Apparently it only takes 20 minutes to setup source control, bug and issue tracking and automated build with it.

Finally, another great piece of news is that this release also ships with a Go-live license, so this can be used for production projects if you wish :)

If you are a member of MSDN and want to download the beta now, you can get it from here.

For more information on the release visit Scott Gu’s blog where you he has started a series of posts on the new features in 2010 Beta 2.

Have any of you been using Beta 1? Will you be using Beta 2? What do you think of the way 2010 and .Net 4.0 are shaping up?

Share this Post:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DotNetKicks
  • Reddit
  • StumbleUpon
  • TwitThis

Technorati Tags: , , ,

Tags: , , ,

Silverlight Coming to Mobile

September 25th, 2009 Posted in .Net, Silverlight, Windows Mobile | 1 Comment »

Ok, so this is not exactly a surprise to many people, but as posted on the Expression team blog, the Silverlight team have announced that Silverlight will be integrated into Windows Mobile 7, the reboot of the mobile OS from Microsoft.

According to the Silverlight team, they are totally commited to having Silverlight work on all mediums, from desktop PCs, TVs and mobile devices.

This comes at a time when Flash is likely to appear on more and more mobile devices soon, but with the success of Flash Lite…well…not really being a success, it remains to be seen how well the next wave of Flash mobile will be accepted.  It certainly looks like Silverlight might have the upper hand here if things continue as they are.

There has been talk about Silverlight coming to the mobile platform for some time, with a lot of people for a while, myself included, expecting it to arrive in time for Windows Mobile 6.5, which is due for release in around a month.  However, 6.5 is only an interrim release until the complete overhaul that is Windows Mobile 7 is released.

So, are you excited about seeing Silverlight on mobile devices? do you think it will be a good thing or a bad thing? or could you not care less?

Share this Post:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DotNetKicks
  • Reddit
  • StumbleUpon
  • TwitThis

Technorati Tags: , ,

Tags: , ,

Scott Guthrie – Manchester – September 2009 – ASP.Net 4.0, MVC, Silverlight 3, VS 2010

September 16th, 2009 Posted in .Net, ASP.NET MVC, ASP.Net, Silverlight, microsoft | 2 Comments »

scottguthrie

Scott Guthrie, Microsoft’s Corporate Vice Presedent and all round .Net Guru is coming to Manchester, UK, later this month to talk about what’s new with Visual Studio 2010, ASP.Net 4.0, Silverlight 3 and upcoming improvements to the MVC Framework!

Seating for this event, entitled Guathon 2009,  is very limited and as such you can only join the wait list at the moment, but I have been lucky enough to secure a place at what promises to be a fantastic workshop.

The announcement on the event home page over at DeveloperDeveloperDeveloper also has a funny section of “things you might not know about Scott Gu”, such as;

  • When Scott Guthrie throws exceptions, it’s across the room.
  • All arrays Scott Guthrie declares are of infinite size, because Scott Guthrie knows no bounds.
  • Scott Guthrie doesn’t have disk latency because the hard drive knows to hurry the hell up.
  • Scott Guthrie writes code that optimizes itself.
  • Scott Guthrie can’t test for equality because he has no equal.
  • Scott Guthrie doesn’t need garbage collection because he doesn’t call .Dispose(), he calls .DropKick().
  • For the rest of this amusing list and more info on the event or to add yourself to the wait list, visit the event home page.

    Share this Post:
    • Digg
    • Sphinn
    • del.icio.us
    • Facebook
    • Google Bookmarks
    • DotNetKicks
    • Reddit
    • StumbleUpon
    • TwitThis

    Technorati Tags: , , , , ,

    Tags: , , , , ,

    Resharper for Visual Studio 2010 Available!

    September 16th, 2009 Posted in .Net, Betas, visual studio | No Comments »

    resharper
    Ok, this one completely slipped by me! A while back I told you that JetBrains had a page on their web site stating that a preview of ReSharper for Visual Studio 2010 was on its way and that we would see it in June….but there was nothing.  Turns out it has been there since July in the form of Nightly Builds available for download, there was just no major announcement made.

    Anyway, if you want to get your hands on it you can download it from here .  To install it just make sure the extension is .Vsix, IE seems to download and save this as a zip so you may need to rename it, and the Visual Studio 2010 extension manager will take over from here and take you through the short installation.

    Once it is installed, open Visual Studio, where you will need to enter the licence information provided on the download page.  It is telling me that it is going to expire on the 22nd September at the moment, but this may be extended further until VS 2010 beta 2 is released later in the year.

    Anyway, as you can see, I now have mine ready to rock and roll so enjoy!

    Share this Post:
    • Digg
    • Sphinn
    • del.icio.us
    • Facebook
    • Google Bookmarks
    • DotNetKicks
    • Reddit
    • StumbleUpon
    • TwitThis

    Technorati Tags: ,

    Tags: ,